// Email templates for Spanglish platform // These are the default templates that get seeded into the database export interface EmailVariable { name: string; description: string; example: string; } export interface DefaultTemplate { name: string; slug: string; subject: string; subjectEs: string; bodyHtml: string; bodyHtmlEs: string; bodyText: string; bodyTextEs: string; description: string; variables: EmailVariable[]; isSystem: boolean; } // Common variables available in all templates export const commonVariables: EmailVariable[] = [ { name: 'siteName', description: 'Website name', example: 'Spanglish' }, { name: 'siteUrl', description: 'Website URL', example: 'https://spanglish.com' }, { name: 'currentYear', description: 'Current year', example: '2026' }, { name: 'supportEmail', description: 'Support email address', example: 'hello@spanglish.com' }, ]; // Booking-specific variables export const bookingVariables: EmailVariable[] = [ { name: 'attendeeName', description: 'Attendee full name', example: 'John Doe' }, { name: 'attendeeEmail', description: 'Attendee email', example: 'john@example.com' }, { name: 'ticketId', description: 'Unique ticket ID', example: 'TKT-ABC123' }, { name: 'qrCode', description: 'QR code for check-in', example: 'data:image/png;base64,...' }, { name: 'ticketPdfUrl', description: 'URL to download ticket PDF', example: 'https://api.spanglish.com/api/tickets/abc123/pdf' }, { name: 'eventTitle', description: 'Event title', example: 'Spanglish Night - January Edition' }, { name: 'eventDate', description: 'Event date formatted', example: 'January 28, 2026' }, { name: 'eventTime', description: 'Event time', example: '7:00 PM' }, { name: 'eventLocation', description: 'Event location', example: 'Casa Cultural, Asunción' }, { name: 'eventLocationUrl', description: 'Google Maps link', example: 'https://maps.google.com/...' }, { name: 'eventPrice', description: 'Event price with currency', example: '50,000 PYG' }, ]; // Payment-specific variables export const paymentVariables: EmailVariable[] = [ { name: 'paymentAmount', description: 'Payment amount with currency', example: '50,000 PYG' }, { name: 'paymentMethod', description: 'Payment method used', example: 'Lightning' }, { name: 'paymentReference', description: 'Payment reference ID', example: 'PAY-XYZ789' }, { name: 'paymentDate', description: 'Payment date', example: 'January 28, 2026' }, ]; // Payment instructions variables (for manual payment methods) export const paymentInstructionsVariables: EmailVariable[] = [ { name: 'tpagoLink', description: 'TPago payment link', example: 'https://tpago.com.py/...' }, { name: 'bankName', description: 'Bank name', example: 'Banco Itaú' }, { name: 'bankAccountHolder', description: 'Account holder name', example: 'Spanglish SRL' }, { name: 'bankAccountNumber', description: 'Bank account number', example: '1234567890' }, { name: 'bankAlias', description: 'Bank alias or phone', example: '0981-123-456' }, { name: 'bankPhone', description: 'Bank phone number', example: '0981-123-456' }, ]; // Base HTML wrapper for all emails export const baseEmailWrapper = ` {{subject}}
Spanglish
{{content}}
`; // Default templates export const defaultTemplates: DefaultTemplate[] = [ { name: 'Booking Confirmation', slug: 'booking-confirmation', subject: 'Your Spanglish ticket is confirmed 🎉', subjectEs: 'Tu entrada de Spanglish está confirmada 🎉', bodyHtml: `

Your Booking is Confirmed!

Hi {{attendeeName}},

Great news! Your spot for {{eventTitle}} has been confirmed. We can't wait to see you there!

📅 Event Details

Event: {{eventTitle}}
Date: {{eventDate}}
Time: {{eventTime}}
Location: {{eventLocation}}
{{#if eventLocationUrl}}

📍 View on Map

{{/if}}

Your Ticket ID

{{qrCode}}

{{#if ticketPdfUrl}}

📄 Download Your Ticket (PDF)

{{/if}}
💡 Important: Please arrive 10-15 minutes early for check-in. Show the PDF ticket or this email at the entrance.

See you at Spanglish!

The Spanglish Team

`, bodyHtmlEs: `

¡Tu Reserva está Confirmada!

Hola {{attendeeName}},

¡Excelentes noticias! Tu lugar para {{eventTitle}} ha sido confirmado. ¡No podemos esperar a verte ahí!

📅 Detalles del Evento

Evento: {{eventTitle}}
Fecha: {{eventDate}}
Hora: {{eventTime}}
Ubicación: {{eventLocation}}
{{#if eventLocationUrl}}

📍 Ver en el Mapa

{{/if}}

Tu ID de Ticket

{{qrCode}}

{{#if ticketPdfUrl}}

📄 Descargar Tu Ticket (PDF)

{{/if}}
💡 Importante: Por favor llega 10-15 minutos antes para el check-in. Muestra el PDF del ticket o este email en la entrada.

¡Nos vemos en Spanglish!

El Equipo de Spanglish

`, bodyText: `Your Booking is Confirmed! Hi {{attendeeName}}, Great news! Your spot for {{eventTitle}} has been confirmed. Event Details: - Event: {{eventTitle}} - Date: {{eventDate}} - Time: {{eventTime}} - Location: {{eventLocation}} Your Ticket ID: {{ticketId}} Important: Please arrive 10-15 minutes early for check-in. Bring your ticket ID or show this email. See you at Spanglish! The Spanglish Team`, bodyTextEs: `¡Tu Reserva está Confirmada! Hola {{attendeeName}}, ¡Excelentes noticias! Tu lugar para {{eventTitle}} ha sido confirmado. Detalles del Evento: - Evento: {{eventTitle}} - Fecha: {{eventDate}} - Hora: {{eventTime}} - Ubicación: {{eventLocation}} Tu ID de Ticket: {{ticketId}} Importante: Por favor llega 10-15 minutos antes para el check-in. Trae tu ID de ticket o muestra este email. ¡Nos vemos en Spanglish! El Equipo de Spanglish`, description: 'Sent automatically when a booking is confirmed after payment', variables: [...commonVariables, ...bookingVariables], isSystem: true, }, { name: 'Payment Receipt', slug: 'payment-receipt', subject: 'Payment Receipt - Spanglish', subjectEs: 'Recibo de Pago - Spanglish', bodyHtml: `

Payment Received

Hi {{attendeeName}},

Thank you for your payment! Here's your receipt for your records.

💳 Payment Details

Amount: {{paymentAmount}}
Method: {{paymentMethod}}
Reference: {{paymentReference}}
Date: {{paymentDate}}

📅 Event

Event: {{eventTitle}}
Date: {{eventDate}}
Ticket ID: {{ticketId}}

Keep this email as your payment confirmation.

The Spanglish Team

`, bodyHtmlEs: `

Pago Recibido

Hola {{attendeeName}},

¡Gracias por tu pago! Aquí está tu recibo para tus registros.

💳 Detalles del Pago

Monto: {{paymentAmount}}
Método: {{paymentMethod}}
Referencia: {{paymentReference}}
Fecha: {{paymentDate}}

📅 Evento

Evento: {{eventTitle}}
Fecha: {{eventDate}}
ID de Ticket: {{ticketId}}

Guarda este email como tu confirmación de pago.

El Equipo de Spanglish

`, bodyText: `Payment Received Hi {{attendeeName}}, Thank you for your payment! Here's your receipt: Payment Details: - Amount: {{paymentAmount}} - Method: {{paymentMethod}} - Reference: {{paymentReference}} - Date: {{paymentDate}} Event: {{eventTitle}} Date: {{eventDate}} Ticket ID: {{ticketId}} Keep this email as your payment confirmation. The Spanglish Team`, bodyTextEs: `Pago Recibido Hola {{attendeeName}}, ¡Gracias por tu pago! Aquí está tu recibo: Detalles del Pago: - Monto: {{paymentAmount}} - Método: {{paymentMethod}} - Referencia: {{paymentReference}} - Fecha: {{paymentDate}} Evento: {{eventTitle}} Fecha: {{eventDate}} ID de Ticket: {{ticketId}} Guarda este email como tu confirmación de pago. El Equipo de Spanglish`, description: 'Sent automatically after payment is processed', variables: [...commonVariables, ...bookingVariables, ...paymentVariables], isSystem: true, }, { name: 'Event Update', slug: 'event-update', subject: 'Important Update: {{eventTitle}}', subjectEs: 'Actualización Importante: {{eventTitle}}', bodyHtml: `

Important Event Update

Hi {{attendeeName}},

We have an important update regarding {{eventTitle}}.

📢 Message

{{customMessage}}

📅 Event Details

Event: {{eventTitle}}
Date: {{eventDate}}
Time: {{eventTime}}
Location: {{eventLocation}}

If you have any questions, please don't hesitate to contact us.

The Spanglish Team

`, bodyHtmlEs: `

Actualización Importante del Evento

Hola {{attendeeName}},

Tenemos una actualización importante sobre {{eventTitle}}.

📢 Mensaje

{{customMessage}}

📅 Detalles del Evento

Evento: {{eventTitle}}
Fecha: {{eventDate}}
Hora: {{eventTime}}
Ubicación: {{eventLocation}}

Si tienes alguna pregunta, no dudes en contactarnos.

El Equipo de Spanglish

`, bodyText: `Important Event Update Hi {{attendeeName}}, We have an important update regarding {{eventTitle}}. Message: {{customMessage}} Event Details: - Event: {{eventTitle}} - Date: {{eventDate}} - Time: {{eventTime}} - Location: {{eventLocation}} If you have any questions, please don't hesitate to contact us. The Spanglish Team`, bodyTextEs: `Actualización Importante del Evento Hola {{attendeeName}}, Tenemos una actualización importante sobre {{eventTitle}}. Mensaje: {{customMessage}} Detalles del Evento: - Evento: {{eventTitle}} - Fecha: {{eventDate}} - Hora: {{eventTime}} - Ubicación: {{eventLocation}} Si tienes alguna pregunta, no dudes en contactarnos. El Equipo de Spanglish`, description: 'Template for sending event updates to attendees (sent manually)', variables: [ ...commonVariables, ...bookingVariables, { name: 'customMessage', description: 'Custom message from admin', example: 'The venue has changed...' } ], isSystem: true, }, { name: 'Post-Event Follow-Up', slug: 'post-event-followup', subject: 'Thanks for joining {{eventTitle}}! 🙏', subjectEs: '¡Gracias por asistir a {{eventTitle}}! 🙏', bodyHtml: `

Thank You for Joining Us!

Hi {{attendeeName}},

Thank you so much for being part of {{eventTitle}}! We hope you had a great time practicing languages and meeting new people.

💬 Share Your Experience

{{customMessage}}

{{#if nextEventTitle}}

📅 Next Event

Event: {{nextEventTitle}}
Date: {{nextEventDate}}

Reserve Your Spot

{{/if}}

Follow us on social media for updates and photos from the event!

See you at the next Spanglish!

The Spanglish Team

`, bodyHtmlEs: `

¡Gracias por Unirte!

Hola {{attendeeName}},

¡Muchas gracias por ser parte de {{eventTitle}}! Esperamos que hayas pasado un gran momento practicando idiomas y conociendo gente nueva.

💬 Comparte tu Experiencia

{{customMessage}}

{{#if nextEventTitle}}

📅 Próximo Evento

Evento: {{nextEventTitle}}
Fecha: {{nextEventDate}}

Reserva tu Lugar

{{/if}}

¡Síguenos en redes sociales para actualizaciones y fotos del evento!

¡Nos vemos en el próximo Spanglish!

El Equipo de Spanglish

`, bodyText: `Thank You for Joining Us! Hi {{attendeeName}}, Thank you so much for being part of {{eventTitle}}! We hope you had a great time. {{customMessage}} Follow us on social media for updates and photos from the event! See you at the next Spanglish! The Spanglish Team`, bodyTextEs: `¡Gracias por Unirte! Hola {{attendeeName}}, ¡Muchas gracias por ser parte de {{eventTitle}}! Esperamos que hayas pasado un gran momento. {{customMessage}} ¡Síguenos en redes sociales para actualizaciones y fotos del evento! ¡Nos vemos en el próximo Spanglish! El Equipo de Spanglish`, description: 'Template for post-event follow-up emails (sent manually)', variables: [ ...commonVariables, ...bookingVariables, { name: 'customMessage', description: 'Custom message from admin', example: 'We would love to hear your feedback!' }, { name: 'nextEventTitle', description: 'Next event title (optional)', example: 'Spanglish Night - February' }, { name: 'nextEventDate', description: 'Next event date (optional)', example: 'February 25, 2026' }, { name: 'nextEventUrl', description: 'Next event booking URL (optional)', example: 'https://spanglish.com/book/...' }, ], isSystem: true, }, { name: 'Custom Email', slug: 'custom-email', subject: '{{customSubject}}', subjectEs: '{{customSubject}}', bodyHtml: `

{{customTitle}}

Hi {{attendeeName}},

{{customMessage}}

The Spanglish Team

`, bodyHtmlEs: `

{{customTitle}}

Hola {{attendeeName}},

{{customMessage}}

El Equipo de Spanglish

`, bodyText: `{{customTitle}} Hi {{attendeeName}}, {{customMessage}} The Spanglish Team`, bodyTextEs: `{{customTitle}} Hola {{attendeeName}}, {{customMessage}} El Equipo de Spanglish`, description: 'Blank template for fully custom emails', variables: [ ...commonVariables, { name: 'attendeeName', description: 'Recipient name', example: 'John Doe' }, { name: 'customSubject', description: 'Email subject', example: 'Special Announcement' }, { name: 'customTitle', description: 'Email title/heading', example: 'Special Announcement' }, { name: 'customMessage', description: 'Email body content (supports HTML)', example: '

Your message here...

' }, ], isSystem: true, }, { name: 'Payment Instructions - TPago', slug: 'payment-instructions-tpago', subject: 'Complete your payment for Spanglish', subjectEs: 'Completa tu pago para Spanglish', bodyHtml: `

You're Almost In! 🎉

Hi {{attendeeName}},

To complete your booking for:

{{eventTitle}}

📅 Date: {{eventDate}}
📍 Location: {{eventLocation}}
💰 Amount: {{paymentAmount}}

Please complete your payment using TPago at the link below:

👉 Pay with Card

If the button doesn't work: {{tpagoLink}}

Important - Manual Verification Process:
Please make sure you complete the payment before clicking "I have paid".
The Spanglish team will review the payment manually.
Your booking is only confirmed after you receive a confirmation email from us.
After completing the payment:
Return to the website and click "I have paid" or click the button below to notify us.

✓ I Have Paid

Or use this link: {{bookingUrl}}

If you have any questions, just reply to this email.

See you soon,
Spanglish

`, bodyHtmlEs: `

¡Ya Casi Estás! 🎉

Hola {{attendeeName}},

Para completar tu reserva para:

{{eventTitle}}

📅 Fecha: {{eventDate}}
📍 Ubicación: {{eventLocation}}
💰 Monto: {{paymentAmount}}

Por favor completa tu pago usando TPago en el siguiente enlace:

👉 Pagar con Tarjeta

Si el botón no funciona: {{tpagoLink}}

Importante - Proceso de Verificación Manual:
Por favor asegúrate de completar el pago antes de hacer clic en "Ya pagué".
El equipo de Spanglish revisará el pago manualmente.
Tu reserva solo será confirmada después de que recibas un email de confirmación de nuestra parte.
Después de completar el pago:
Vuelve al sitio web y haz clic en "Ya pagué" o haz clic en el botón de abajo para notificarnos.

✓ Ya Pagué

O usa este enlace: {{bookingUrl}}

Si tienes alguna pregunta, simplemente responde a este email.

¡Nos vemos pronto!
Spanglish

`, bodyText: `You're Almost In! Hi {{attendeeName}}, To complete your booking for: {{eventTitle}} 📅 Date: {{eventDate}} 📍 Location: {{eventLocation}} 💰 Amount: {{paymentAmount}} Please complete your payment using TPago at the link below: 👉 Pay with card: {{tpagoLink}} ⚠️ IMPORTANT - Manual Verification Process: Please make sure you complete the payment before clicking "I have paid". The Spanglish team will review the payment manually. Your booking is only confirmed after you receive a confirmation email from us. After completing the payment, return to the website and click "I have paid" or use this link to notify us: {{bookingUrl}} If you have any questions, just reply to this email. See you soon, Spanglish`, bodyTextEs: `¡Ya Casi Estás! Hola {{attendeeName}}, Para completar tu reserva para: {{eventTitle}} 📅 Fecha: {{eventDate}} 📍 Ubicación: {{eventLocation}} 💰 Monto: {{paymentAmount}} Por favor completa tu pago usando TPago en el siguiente enlace: 👉 Pagar con tarjeta: {{tpagoLink}} ⚠️ IMPORTANTE - Proceso de Verificación Manual: Por favor asegúrate de completar el pago antes de hacer clic en "Ya pagué". El equipo de Spanglish revisará el pago manualmente. Tu reserva solo será confirmada después de que recibas un email de confirmación de nuestra parte. Después de completar el pago, vuelve al sitio web y haz clic en "Ya pagué" o usa este enlace para notificarnos: {{bookingUrl}} Si tienes alguna pregunta, simplemente responde a este email. ¡Nos vemos pronto! Spanglish`, description: 'Sent when user selects TPago payment and clicks continue to payment', variables: [ ...commonVariables, ...bookingVariables, { name: 'paymentAmount', description: 'Payment amount with currency', example: '50,000 PYG' }, { name: 'tpagoLink', description: 'TPago payment link', example: 'https://tpago.com.py/...' }, { name: 'bookingUrl', description: 'URL to return to payment page', example: 'https://spanglish.com/booking/abc123?step=payment' }, ], isSystem: true, }, { name: 'Payment Instructions - Bank Transfer', slug: 'payment-instructions-bank-transfer', subject: 'Bank transfer details for your Spanglish booking', subjectEs: 'Datos de transferencia para tu reserva en Spanglish', bodyHtml: `

Thanks for Joining Spanglish! 🙂

Hi {{attendeeName}},

Here are the bank transfer details for your booking:

{{eventTitle}}

📅 Date: {{eventDate}}
💰 Amount: {{paymentAmount}}

🏦 Bank Transfer Details

{{#if bankName}}
Bank: {{bankName}}
{{/if}} {{#if bankAccountHolder}}
Account Holder: {{bankAccountHolder}}
{{/if}} {{#if bankAccountNumber}}
Account Number: {{bankAccountNumber}}
{{/if}} {{#if bankAlias}}
Alias: {{bankAlias}}
{{/if}} {{#if bankPhone}}
Phone: {{bankPhone}}
{{/if}}
Reference: {{paymentReference}}
Important - Manual Verification Process:
Please make sure you complete the payment before clicking "I have paid".
The Spanglish team will review the payment manually.
Your booking is only confirmed after you receive a confirmation email from us.
After making the transfer:
Return to the website and click "I have paid" or click the button below to notify us.

✓ I Have Paid

Or use this link: {{bookingUrl}}

If you need help, reply to this email.

See you at the event,
Spanglish

`, bodyHtmlEs: `

¡Gracias por unirte a Spanglish! 🙂

Hola {{attendeeName}},

Aquí están los datos de transferencia para tu reserva:

{{eventTitle}}

📅 Fecha: {{eventDate}}
💰 Monto: {{paymentAmount}}

🏦 Datos de Transferencia

{{#if bankName}}
Banco: {{bankName}}
{{/if}} {{#if bankAccountHolder}}
Titular: {{bankAccountHolder}}
{{/if}} {{#if bankAccountNumber}}
Nro. Cuenta: {{bankAccountNumber}}
{{/if}} {{#if bankAlias}}
Alias: {{bankAlias}}
{{/if}} {{#if bankPhone}}
Teléfono: {{bankPhone}}
{{/if}}
Referencia: {{paymentReference}}
Importante - Proceso de Verificación Manual:
Por favor asegúrate de completar el pago antes de hacer clic en "Ya pagué".
El equipo de Spanglish revisará el pago manualmente.
Tu reserva solo será confirmada después de que recibas un email de confirmación de nuestra parte.
Después de realizar la transferencia:
Vuelve al sitio web y haz clic en "Ya pagué" o haz clic en el botón de abajo para notificarnos.

✓ Ya Pagué

O usa este enlace: {{bookingUrl}}

Si necesitas ayuda, responde a este email.

¡Nos vemos en el evento!
Spanglish

`, bodyText: `Thanks for Joining Spanglish! Hi {{attendeeName}}, Here are the bank transfer details for your booking: {{eventTitle}} 📅 Date: {{eventDate}} 💰 Amount: {{paymentAmount}} Bank Transfer Details: - Bank: {{bankName}} - Account Holder: {{bankAccountHolder}} - Account Number: {{bankAccountNumber}} - Alias: {{bankAlias}} - Phone: {{bankPhone}} - Reference: {{paymentReference}} ⚠️ IMPORTANT - Manual Verification Process: Please make sure you complete the payment before clicking "I have paid". The Spanglish team will review the payment manually. Your booking is only confirmed after you receive a confirmation email from us. After making the transfer, return to the website and click "I have paid" or use this link to notify us: {{bookingUrl}} If you need help, reply to this email. See you at the event, Spanglish`, bodyTextEs: `¡Gracias por unirte a Spanglish! Hola {{attendeeName}}, Aquí están los datos de transferencia para tu reserva: {{eventTitle}} 📅 Fecha: {{eventDate}} 💰 Monto: {{paymentAmount}} Datos de Transferencia: - Banco: {{bankName}} - Titular: {{bankAccountHolder}} - Nro. Cuenta: {{bankAccountNumber}} - Alias: {{bankAlias}} - Teléfono: {{bankPhone}} - Referencia: {{paymentReference}} ⚠️ IMPORTANTE - Proceso de Verificación Manual: Por favor asegúrate de completar el pago antes de hacer clic en "Ya pagué". El equipo de Spanglish revisará el pago manualmente. Tu reserva solo será confirmada después de que recibas un email de confirmación de nuestra parte. Después de completar el pago, vuelve al sitio web y haz clic en "Ya pagué" o usa este enlace para notificarnos: {{bookingUrl}} Si necesitas ayuda, responde a este email. ¡Nos vemos en el evento! Spanglish`, description: 'Sent when user selects bank transfer payment and clicks continue to payment', variables: [ ...commonVariables, ...bookingVariables, { name: 'paymentAmount', description: 'Payment amount with currency', example: '50,000 PYG' }, { name: 'paymentReference', description: 'Unique payment reference', example: 'SPG-ABC123' }, { name: 'bankName', description: 'Bank name', example: 'Banco Itaú' }, { name: 'bankAccountHolder', description: 'Account holder name', example: 'Spanglish SRL' }, { name: 'bankAccountNumber', description: 'Bank account number', example: '1234567890' }, { name: 'bankAlias', description: 'Bank alias', example: 'spanglish.py' }, { name: 'bankPhone', description: 'Bank phone number', example: '0981-123-456' }, { name: 'bookingUrl', description: 'URL to return to payment page', example: 'https://spanglish.com/booking/abc123?step=payment' }, ], isSystem: true, }, { name: 'Payment Rejected', slug: 'payment-rejected', subject: 'Payment not found for your Spanglish booking', subjectEs: 'No encontramos el pago de tu reserva en Spanglish', bodyHtml: `

About Your Booking

Hi {{attendeeName}},

Thanks for your interest in Spanglish.

Unfortunately, we were unable to find or confirm the payment for your booking for:

{{eventTitle}}

📅 Date: {{eventDate}}
📍 Location: {{eventLocation}}

Because of this, the booking has been cancelled.

Did you already pay?
If you believe this was a mistake or if you have already made the payment, please reply to this email and we'll be happy to check it with you.

You're always welcome to make a new booking if spots are still available.

{{#if newBookingUrl}}

Make a New Booking

{{/if}}

Warm regards,
Spanglish

`, bodyHtmlEs: `

Sobre Tu Reserva

Hola {{attendeeName}},

Gracias por tu interés en Spanglish.

Lamentablemente, no pudimos encontrar o confirmar el pago de tu reserva para:

{{eventTitle}}

📅 Fecha: {{eventDate}}
📍 Ubicación: {{eventLocation}}

Por esta razón, la reserva ha sido cancelada.

¿Ya realizaste el pago?
Si crees que esto fue un error o si ya realizaste el pago, por favor responde a este correo y con gusto lo revisaremos contigo.

Siempre eres bienvenido/a a hacer una nueva reserva si aún hay lugares disponibles.

{{#if newBookingUrl}}

Hacer una Nueva Reserva

{{/if}}

Saludos cordiales,
Spanglish

`, bodyText: `About Your Booking Hi {{attendeeName}}, Thanks for your interest in Spanglish. Unfortunately, we were unable to find or confirm the payment for your booking for: {{eventTitle}} 📅 Date: {{eventDate}} 📍 Location: {{eventLocation}} Because of this, the booking has been cancelled. If you believe this was a mistake or if you have already made the payment, please reply to this email and we'll be happy to check it with you. You're always welcome to make a new booking if spots are still available. Warm regards, Spanglish`, bodyTextEs: `Sobre Tu Reserva Hola {{attendeeName}}, Gracias por tu interés en Spanglish. Lamentablemente, no pudimos encontrar o confirmar el pago de tu reserva para: {{eventTitle}} 📅 Fecha: {{eventDate}} 📍 Ubicación: {{eventLocation}} Por esta razón, la reserva ha sido cancelada. Si crees que esto fue un error o si ya realizaste el pago, por favor responde a este correo y con gusto lo revisaremos contigo. Siempre eres bienvenido/a a hacer una nueva reserva si aún hay lugares disponibles. Saludos cordiales, Spanglish`, description: 'Sent when admin rejects a TPago or Bank Transfer payment', variables: [ ...commonVariables, ...bookingVariables, { name: 'newBookingUrl', description: 'URL to make a new booking (optional)', example: 'https://spanglish.com/book/event123' }, ], isSystem: true, }, ]; // Helper function to replace template variables export function replaceTemplateVariables(template: string, variables: Record): string { let result = template; // Handle conditional blocks {{#if variable}}...{{/if}} const conditionalRegex = /\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g; result = result.replace(conditionalRegex, (match, varName, content) => { return variables[varName] ? content : ''; }); // Replace simple variables {{variable}} const variableRegex = /\{\{(\w+)\}\}/g; result = result.replace(variableRegex, (match, varName) => { return variables[varName] !== undefined ? String(variables[varName]) : match; }); return result; } // Helper to wrap content in the base template export function wrapInBaseTemplate(content: string, variables: Record): string { const wrappedContent = baseEmailWrapper.replace('{{content}}', content); return replaceTemplateVariables(wrappedContent, variables); } // Get all available variables for a template by slug export function getTemplateVariables(slug: string): EmailVariable[] { const template = defaultTemplates.find(t => t.slug === slug); return template?.variables || commonVariables; }