import { brandingPrimaryColor, renderShell, type BrandingShell } from '@/lib/email/shell'; export interface InquiryClientConfirmationData { firstName: string; mooringNumber: string | null; contactEmail: string; /** Display name; falls back to "Port Nimara". */ portName?: string; } interface RenderOpts { branding?: BrandingShell | null; } export function inquiryClientConfirmation( data: InquiryClientConfirmationData, overrides?: RenderOpts, ) { const { firstName, mooringNumber, contactEmail } = data; const portName = data.portName ?? 'Port Nimara'; const berthText = mooringNumber ? `Berth ${mooringNumber}` : `a ${portName} Berth`; const subject = mooringNumber ? `Thank You for Your Interest in Berth ${mooringNumber}` : `Thank You for Your Interest in a ${portName} Berth`; const accent = brandingPrimaryColor(overrides?.branding); const body = `

Dear ${escapeHtml(firstName)},

Thank you for expressing interest in ${escapeHtml(berthText)}. Our team has registered your interest, and we will reach out to you very shortly by your preferred method of contact with more information.

If you have any questions, please feel free to reach out to us at ${escapeHtml(contactEmail)}.

Best regards,
The ${escapeHtml(portName)} Sales Team

`; const text = [ `Dear ${firstName},`, '', `Thank you for expressing interest in ${berthText}. Our team has registered your interest, and we will reach out to you very shortly by your preferred method of contact with more information.`, '', `If you have any questions, please feel free to reach out to us at ${contactEmail}.`, '', 'Best regards,', `The ${portName} Sales Team`, ].join('\n'); return { subject, html: renderShell({ title: subject, body, branding: overrides?.branding }), text, }; } function escapeHtml(str: string): string { return str .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); }