import { Badge, DataTable, DocumentShell, KeyValueGrid, Section } from '@/lib/pdf/brand-kit'; export interface ClientContact { channel: string; value: string; label?: string | null; isPrimary: boolean | null; } export interface YachtRow { name: string; lengthFt: string | null; widthFt: string | null; draftFt: string | null; lengthM: string | null; widthM: string | null; draftM: string | null; } export interface InterestRow { id: string; pipelineStage: string | null; leadCategory: string | null; berthMooringNumber: string | null; createdAt: Date | string; } export interface ActivityRow { action: string; entityType: string; fieldChanged?: string | null; createdAt: Date | string; } export interface ClientSummaryPdfProps { portName: string; logoBuffer: Buffer | null; client: { fullName: string | null; nationality?: string | null; source?: string | null; createdAt: Date | string; }; contacts: ClientContact[]; yachts: YachtRow[]; interests: InterestRow[]; activity: ActivityRow[]; } function fmtDate(d: Date | string | null | undefined): string { if (!d) return '—'; return new Date(d).toISOString().slice(0, 10); } function yachtDims(y: YachtRow): string { const parts = [ y.lengthFt ? `${y.lengthFt}ft` : y.lengthM ? `${y.lengthM}m` : null, y.widthFt ? `${y.widthFt}ft beam` : null, y.draftFt ? `${y.draftFt}ft draft` : null, ].filter(Boolean); return parts.length ? parts.join(' · ') : '—'; } export function ClientSummaryPdf({ portName, logoBuffer, client, contacts, yachts, interests, activity, }: ClientSummaryPdfProps) { const docMeta = `${client.fullName ?? 'Client'} · ${contacts.length} contact${ contacts.length === 1 ? '' : 's' } · ${yachts.length} yacht${yachts.length === 1 ? '' : 's'} · ${interests.length} interest${ interests.length === 1 ? '' : 's' }`; return (
columns={[ { header: 'Channel', flex: 1, render: (c) => c.channel }, { header: 'Value', flex: 3, render: (c) => `${c.value}${c.label ? ` (${c.label})` : ''}`, }, { header: 'Primary', flex: 1, align: 'center', render: (c) => (c.isPrimary ? : '—'), }, ]} rows={contacts} emptyMessage="No contacts on file." />
columns={[ { header: 'Name', flex: 3, render: (y) => y.name }, { header: 'Dimensions', flex: 4, render: (y) => yachtDims(y) }, ]} rows={yachts} emptyMessage="No yachts linked to this client." />
columns={[ { header: 'Stage', flex: 2, render: (i) => i.pipelineStage ?? 'open' }, { header: 'Berth', flex: 1, render: (i) => i.berthMooringNumber ?? '—' }, { header: 'Category', flex: 2, render: (i) => i.leadCategory ?? '—' }, { header: 'Created', flex: 1.5, render: (i) => fmtDate(i.createdAt) }, ]} rows={interests} emptyMessage="No pipeline interests on file." />
columns={[ { header: 'When', flex: 1.5, render: (a) => fmtDate(a.createdAt) }, { header: 'Action', flex: 1.5, render: (a) => a.action }, { header: 'Entity', flex: 1.5, render: (a) => a.entityType }, { header: 'Field', flex: 1.5, render: (a) => a.fieldChanged ?? '—' }, ]} rows={activity} emptyMessage="No recent activity." />
); }