feat: wire welcome email for new member creation
This commit is contained in:
parent
8b7f124f15
commit
a32e4de2ac
2 changed files with 43 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import { connectDB } from '../../utils/mongoose.js'
|
|||
import { getSlackService } from '../../utils/slack.ts'
|
||||
import { validateBody } from '../../utils/validateBody.js'
|
||||
import { memberCreateSchema } from '../../utils/schemas.js'
|
||||
import { sendWelcomeEmail } from '../../utils/resend.js'
|
||||
// Simple payment check function to avoid import issues
|
||||
const requiresPayment = (contributionValue) => contributionValue !== '0'
|
||||
|
||||
|
|
@ -98,8 +99,13 @@ export default defineEventHandler(async (event) => {
|
|||
// Payment processing will be added here
|
||||
}
|
||||
|
||||
// TODO: Send welcome email
|
||||
|
||||
// Send welcome email (non-blocking)
|
||||
try {
|
||||
await sendWelcomeEmail(member)
|
||||
} catch (emailError) {
|
||||
console.error('Failed to send welcome email:', emailError)
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
member: {
|
||||
|
|
|
|||
|
|
@ -255,3 +255,38 @@ ${eventList}`,
|
|||
return { success: false, error };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send welcome email to new member
|
||||
*/
|
||||
export async function sendWelcomeEmail(member) {
|
||||
const baseUrl = process.env.BASE_URL || "https://ghostguild.org";
|
||||
|
||||
try {
|
||||
const { data, error } = await resend.emails.send({
|
||||
from: "Ghost Guild <ghostguild@babyghosts.org>",
|
||||
to: [member.email],
|
||||
subject: "Welcome to Ghost Guild",
|
||||
text: `Hi ${member.name},
|
||||
|
||||
Welcome to Ghost Guild! You're now part of the ${member.circle} circle.
|
||||
|
||||
Sign in to your dashboard:
|
||||
${baseUrl}/member/dashboard
|
||||
|
||||
If you have questions, reach out on Slack or reply to this email.
|
||||
|
||||
— Ghost Guild`,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error("Failed to send welcome email:", error);
|
||||
return { success: false, error };
|
||||
}
|
||||
|
||||
return { success: true, data };
|
||||
} catch (error) {
|
||||
console.error("Error sending welcome email:", error);
|
||||
return { success: false, error };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue