// Professional pre-built email template library // Variables: {{first_name}}, {{company_name}}, {{stop_name}}, // {{pickup_date}}, {{order_total}}, {{balance_due}}, {{due_date}}, // {{item_summary}}, {{custom_message}} export type EmailTemplate = { id: string; name: string; description: string; subject: string; body_text: string; body_html: string; }; export const BUILT_IN_TEMPLATES: EmailTemplate[] = [ { id: "order_confirmation", name: "Order Confirmation", description: "Professional order confirmation with item summary and pickup details", subject: "Your Order is Confirmed – {{company_name}}", body_text: `Dear {{first_name}}, Your order has been confirmed and is being prepared for pickup. {{item_summary}} Pickup Date: {{pickup_date}} Location: {{stop_name}} Thank you for choosing {{company_name}}. We'll see you soon! – The {{company_name}} Team`, body_html: `

Order Confirmed ✓

Thank you for your order with {{company_name}}

Hi {{first_name}},

Great news — your order is confirmed and we're getting it ready for you!

Pickup Date{{pickup_date}}
Location{{stop_name}}
Order Total{{order_total}}
{{#if item_summary}}
{{item_summary}}
{{/if}} {{#if custom_message}}
{{custom_message}}
{{/if}}

We'll send you a reminder as your pickup date approaches. See you soon!

— The {{company_name}} Team

`, }, { id: "pickup_reminder", name: "Pickup Reminder", description: "Friendly reminder before pickup date with key details", subject: "Reminder: Your pickup is {{pickup_date}} – {{company_name}}", body_text: `Hi {{first_name}}, This is a friendly reminder that your order is scheduled for pickup: 📅 Date: {{pickup_date}} 📍 Location: {{stop_name}} 💰 Balance Due: {{balance_due}} {{#if custom_message}} {{custom_message}} {{/if}} See you soon! {{company_name}} Team`, body_html: `

⏰ Pickup Reminder

Your order is waiting for you!

Hi {{first_name}},

Just a quick reminder — your order is scheduled for pickup soon!

{{pickup_date}}
{{stop_name}}
Company{{company_name}}
{{#if balance_due}}
{{balance_due}}
Balance Due at Pickup
{{/if}} {{#if custom_message}}
{{custom_message}}
{{/if}}

See you soon!
— {{company_name}} Team

`, }, { id: "promotional", name: "Promotional / Newsletter", description: "Marketing newsletter with headline, body, and call to action", subject: "{{custom_subject}}", body_text: `{{first_name}}, {{custom_message}} {{#if cta_text}} {{cta_text}}: {{cta_url}} {{/if}} Thanks for being a valued customer! {{company_name}} Team`, body_html: `
{{#if tag}}
{{tag}}
{{/if}}

{{headline}}

Hi {{first_name}},

{{custom_message}}

{{#if cta_text}} {{/if}}

You're receiving this because you're a {{company_name}} customer.

`, }, { id: "thank_you", name: "Thank You / Follow-Up", description: "Post-pickup thank you with follow-up call to action", subject: "Thanks for picking up with {{company_name}}!", body_text: `Dear {{first_name}}, Thank you for picking up your order from {{stop_name}}! We hope everything was exactly as you expected. If you have any questions or feedback, please don't hesitate to reach out. {{#if custom_message}} {{custom_message}} {{/if}} We appreciate your business and look forward to seeing you again soon! Warm regards, {{company_name}} Team`, body_html: `

Thank You! 🙏

Your pickup from {{stop_name}} is complete

Dear {{first_name}},

Thank you for picking up your order with us. We hope everything was exactly as you expected!

Questions or feedback? Reply to this email — we read every message.

{{#if custom_message}}
{{custom_message}}
{{/if}}

We appreciate your business and look forward to seeing you again!

Warm regards,
{{company_name}} Team

`, }, { id: "deposit_request", name: "Deposit Request", description: "Professional deposit request for wholesale customers", subject: "Deposit Required – {{company_name}} Order", body_text: `Dear {{first_name}}, Your order with {{company_name}} is almost ready! To confirm and schedule production, we need a deposit to get started. Order Total: {{order_total}} Deposit Required: {{balance_due}} Due By: {{due_date}} {{#if custom_message}} {{custom_message}} {{/if}} To pay your deposit, simply reply to this email or contact us directly. Thank you, {{company_name}} Team`, body_html: `

Deposit Required

Confirm your order with {{company_name}}

Hi {{first_name}},

Your order is in the queue! To confirm and schedule production, we need a deposit to get things started.

{{balance_due}}
Deposit Required
Order Total: {{order_total}}
{{#if due_date}}
⏰ Please pay by {{due_date}}
{{/if}} {{#if custom_message}}
{{custom_message}}
{{/if}}

To pay your deposit, simply reply to this email or contact us directly. We accept cash, check, and wire transfer.

Thank you,
{{company_name}} Team

`, }, ]; // Render a template with given variables (simple mustache-like substitution) export function renderTemplate( template: EmailTemplate, variables: Record ): { subject: string; body_text: string; body_html: string } { function sub(text: string): string { return text.replace(/\{\{(\w+)\}\}/g, (match, key) => variables[key] ?? match); } return { subject: sub(template.subject), body_text: sub(template.body_text), body_html: sub(template.body_html), }; } // Variables available in the template editor export const TEMPLATE_VARIABLES = [ { key: "first_name", label: "First Name", example: "Jane" }, { key: "company_name", label: "Company Name", example: "Route Commerce" }, { key: "stop_name", label: "Stop Name", example: "Tuxedo Warehouse" }, { key: "pickup_date", label: "Pickup Date", example: "May 15, 2026" }, { key: "order_total", label: "Order Total", example: "$450.00" }, { key: "balance_due", label: "Balance Due", example: "$225.00" }, { key: "due_date", label: "Due Date", example: "May 10, 2026" }, { key: "item_summary", label: "Item Summary", example: "10× Tuxedo Set, 5× Shirt" }, { key: "custom_message", label: "Custom Message", example: "See you at the stop!" }, { key: "cta_text", label: "CTA Button Text", example: "Shop Now" }, { key: "cta_url", label: "CTA URL", example: "https://..." }, { key: "tag", label: "Newsletter Tag", example: "New Arrivals" }, { key: "headline", label: "Headline", example: "Spring Collection is Here!" }, { key: "unsubscribe_url", label: "Unsubscribe URL", example: "https://..." }, ] as const;