interface InviteData { link: string; ttlHours: number; recipientName?: string; isSuperAdmin: boolean; } const LOGO_URL = 'https://s3.portnimara.com/images/Port%20Nimara%20New%20Logo-Circular%20Frame_250px.png'; const BACKGROUND_URL = 'https://s3.portnimara.com/images/Overhead_1_blur.png'; function shell(opts: { title: string; body: string }): string { return ` ${opts.title}
Port Nimara Logo
${opts.body}
`; } export function crmInviteEmail(data: InviteData): { subject: string; html: string; text: string; } { const subject = `You're invited to the Port Nimara CRM`; const greeting = data.recipientName ? `Dear ${escapeHtml(data.recipientName)},` : 'Welcome,'; const role = data.isSuperAdmin ? 'super administrator' : 'administrator'; const body = `

Welcome to the Port Nimara CRM

${greeting}

You've been invited to the Port Nimara CRM as a ${role}. Click the button below to set your password and activate your account. The link expires in ${data.ttlHours} hours.

Set up your account

If the button doesn't work, paste this link into your browser:
${data.link}

Thank you,
Port Nimara CRM

`; const text = [ `Welcome to the Port Nimara CRM`, '', `You've been invited as a ${role}.`, `Set up your account: ${data.link}`, '', `The link expires in ${data.ttlHours} hours.`, '', `Thank you,`, `Port Nimara CRM`, ].join('\n'); return { subject, html: shell({ title: subject, body }), text }; } function escapeHtml(str: string): string { return str .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); }