diff --git a/server/api/members/[id]/create-portal-account.post.ts b/server/api/members/[id]/create-portal-account.post.ts index bbe3aac..92c3849 100644 --- a/server/api/members/[id]/create-portal-account.post.ts +++ b/server/api/members/[id]/create-portal-account.post.ts @@ -135,7 +135,7 @@ export default defineEventHandler(async (event) => { const config = useRuntimeConfig(); const verificationLink = `https://portal.monacousa.org/auth/verify?token=${verificationToken}`; - await emailService.sendWelcomeEmail(member.email, { + const emailData = { firstName: member.first_name, lastName: member.last_name, verificationLink, @@ -145,10 +145,19 @@ export default defineEventHandler(async (event) => { month: 'long', day: 'numeric' }) - }); + }; + + // Use appropriate email template based on membership tier + if (membershipTier === 'board') { + console.log('[api/members/[id]/create-portal-account.post] Sending board-specific welcome email'); + await emailService.sendWelcomeBoardEmail(member.email, emailData); + } else { + console.log('[api/members/[id]/create-portal-account.post] Sending standard welcome email'); + await emailService.sendWelcomeEmail(member.email, emailData); + } emailSent = true; - console.log('[api/members/[id]/create-portal-account.post] Welcome email sent successfully'); + console.log(`[api/members/[id]/create-portal-account.post] Welcome email sent successfully (${membershipTier} template)`); } catch (error: any) { emailError = error.message || 'Unknown email error'; console.error('[api/members/[id]/create-portal-account.post] Failed to send welcome email:', emailError); diff --git a/server/templates/welcome-board.hbs b/server/templates/welcome-board.hbs new file mode 100644 index 0000000..64667de --- /dev/null +++ b/server/templates/welcome-board.hbs @@ -0,0 +1,311 @@ + + + + + + + Welcome to the MonacoUSA Board Portal + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + +
+ MonacoUSA +

Welcome to the Board Portal

+

Monaco - United States Association

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Dear Board Member {{firstName}} {{lastName}},

+
+

+ Your MonacoUSA Board Portal account has been successfully created! + Welcome to the board management system where you have special access to oversee association operations, manage members, and coordinate board activities. +

+
+ + + + +
+ + + + + + + + + + +
+ 👑 Board Access Granted +
+ + + + + +
+

Member ID:

+

{{memberId}}

+
+

Portal Access Level:

+

Board Member

+
+
+

+ You have access to board-specific tools including member management, event oversight, and administrative functions. +

+
+
+
+ + + + +
+

📧 Next Step: Verify Your Email

+

+ To activate your board portal access and secure your account, please verify your email address by clicking the button below: +

+ + + + +
+ + ✉️ Verify Email Address + +
+

+ This verification link will expire in 24 hours for security purposes. +

+
+
+ + + + +
+

🛡️ Your Board Access Includes

+ + + + + +
+

👥 Member Management

+

View, edit, and manage all association members

+ +

📅 Event Management

+

Create, edit, and manage association events

+
+

📊 Board Dashboard

+

Access board-specific statistics and insights

+ +

💼 Portal Accounts

+

Create and manage member portal accounts

+
+

+ These features will be available immediately after email verification. +

+
+
+

⭐ Board Member Next Steps

+ + + + + + + + + + + + + +
+ + + + + +
+ 1 + +

+ Verify your email using the button above +

+
+
+ + + + + +
+ 2 + +

+ Access the board portal at portal.monacousa.org/dashboard/board +

+
+
+ + + + + +
+ 3 + +

+ Review board dashboard and familiarize yourself with your tools +

+
+
+ + + + + +
+ 4 + +

+ Begin managing members, events, and association operations +

+
+
+
+ + + + +
+

📞 Board Member Support

+

+ As a board member, you have priority support for any technical questions or assistance needed with the portal. +

+

+ For board-specific support, please contact: board@monacousa.org +

+
+
+

+ Thank you for your service to the MonacoUSA Association. Your board access enables you to help guide our community and manage our operations effectively. +

+
+
+ + + + +
+

MonacoUSA Association

+

Board Portal Access

+ + + + + + + + + + +
+ Board Portal + | + Board Support + | + Website +
+ + + + + + +
+

+ This email was sent to {{email}} regarding your MonacoUSA Board Portal access.
+ If you did not expect this email, please contact board@monacousa.org immediately. +

+
+
+
+
+ + diff --git a/server/utils/email.ts b/server/utils/email.ts index 0957325..eb4c191 100644 --- a/server/utils/email.ts +++ b/server/utils/email.ts @@ -152,7 +152,7 @@ export class EmailService { * Preload and compile email templates */ private preloadTemplates(): void { - const templateNames = ['welcome', 'verification', 'password-reset', 'dues-reminder', 'test']; + const templateNames = ['welcome', 'welcome-board', 'verification', 'password-reset', 'dues-reminder', 'test']; templateNames.forEach(templateName => { try { @@ -263,6 +263,39 @@ export class EmailService { console.log(`[EmailService] ✅ Welcome email sent to ${to}`); } + /** + * Send welcome/verification email to new board members + */ + async sendWelcomeBoardEmail(to: string, data: WelcomeEmailData): Promise { + const template = this.getTemplate('welcome-board'); + if (!template) { + console.error('[EmailService] ❌ Board welcome email template not found! Available templates:', Array.from(this.templates.keys())); + throw new Error('Board welcome email template not found'); + } + + const config = useRuntimeConfig(); + const templateData = { + ...data, + logoUrl: data.logoUrl || 'https://portal.monacousa.org/MONACOUSA-Flags_376x376.png', + baseUrl: config.public.domain || 'https://portal.monacousa.org', + email: data.email || to + }; + + console.log('[EmailService] Board template data:', templateData); + + const html = template(templateData); + console.log('[EmailService] Generated board HTML length:', html.length); + console.log('[EmailService] Board HTML preview (first 200 chars):', html.substring(0, 200)); + + await this.sendEmail({ + to, + subject: 'Welcome to the MonacoUSA Board Portal - Please Verify Your Email', + html + }); + + console.log(`[EmailService] ✅ Board welcome email sent to ${to}`); + } + /** * Send email verification email */