import { brandingPrimaryColor, renderShell, safeUrl, type BrandingShell } from '@/lib/email/shell'; interface InviteData { link: string; ttlHours: number; recipientName?: string; isSuperAdmin: boolean; /** Display name for the port — falls back to "Port Nimara" so the * pre-multi-tenant default still reads correctly. */ portName?: string; } interface RenderOpts { branding?: BrandingShell | null; } export function crmInviteEmail( data: InviteData, overrides?: RenderOpts, ): { subject: string; html: string; text: string; } { const portName = data.portName ?? 'Port Nimara'; const subject = `You're invited to the ${portName} CRM`; const greeting = data.recipientName ? `Dear ${escapeHtml(data.recipientName)},` : 'Welcome,'; const role = data.isSuperAdmin ? 'super administrator' : 'administrator'; const accent = brandingPrimaryColor(overrides?.branding); const body = `
Welcome to the ${escapeHtml(portName)} CRM
${greeting}
You've been invited to the ${escapeHtml(portName)} CRM as a ${role}. Click the button below to set your password and activate your account. The link expires in ${data.ttlHours} hours.
If the button doesn't work, paste this link into your browser:
${data.link}
Thank you,
${escapeHtml(portName)} CRM