Add board-specific welcome email template and logic
All checks were successful
Build And Push Image / docker (push) Successful in 1m43s

- Create separate welcome email template for board members
- Add conditional logic to use board template based on membership tier
- Update email service to support sendWelcomeBoardEmail method
- Include board-specific subject line and template preloading
This commit is contained in:
2025-08-14 09:25:56 +02:00
parent 1ab45cf503
commit 400f9cdd52
3 changed files with 357 additions and 4 deletions

View File

@@ -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<void> {
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
*/