import {
  BarChart,
  DataTable,
  DocumentShell,
  KeyValueGrid,
  PieChart,
  Section,
} from '@/lib/pdf/brand-kit';

export interface BrandingSamplePdfProps {
  portName: string;
  logoBuffer: Buffer | null;
}

const SAMPLE_BARS = [
  { label: 'Mon', value: 14 },
  { label: 'Tue', value: 22 },
  { label: 'Wed', value: 18 },
  { label: 'Thu', value: 27 },
  { label: 'Fri', value: 31 },
  { label: 'Sat', value: 9 },
  { label: 'Sun', value: 5 },
];

const SAMPLE_PIE = [
  { label: 'Available', value: 42 },
  { label: 'Under Offer', value: 12 },
  { label: 'Sold', value: 38 },
];

interface SampleRow {
  date: string;
  action: string;
  who: string;
}

const SAMPLE_ROWS: SampleRow[] = [
  { date: '2026-05-12', action: 'created client', who: 'Sarah K.' },
  { date: '2026-05-12', action: 'sent EOI', who: 'Matt P.' },
  { date: '2026-05-11', action: 'updated berth A12', who: 'Sarah K.' },
  { date: '2026-05-11', action: 'archived interest', who: 'James R.' },
];

/**
 * One-page sample PDF used by the admin Branding UI's "Test with sample PDF"
 * button. Exercises every brand-kit primitive a real report would touch so an
 * admin can sanity-check their logo placement, font/color rendering, header
 * letterboxing, and footer page numbering at a glance.
 */
export function BrandingSamplePdf({ portName, logoBuffer }: BrandingSamplePdfProps) {
  return (
    <DocumentShell
      portName={portName}
      docTitle="Branding Sample"
      docMeta="Generated to verify your port logo and design tokens"
      logoBuffer={logoBuffer}
      pdfTitle="Branding Sample"
    >
      <Section title="Summary" subtitle="A glance at how the brand kit renders in real reports.">
        <KeyValueGrid
          rows={[
            { label: 'Port', value: portName },
            { label: 'Logo source', value: logoBuffer ? 'Configured' : 'Fallback (text)' },
            { label: 'Page size', value: 'A4' },
            { label: 'Color scheme', value: 'Slate header · Blue accent' },
          ]}
        />
      </Section>
      <Section title="Bar chart" subtitle="Sample weekly activity counts.">
        <BarChart data={SAMPLE_BARS} showValues />
      </Section>
      <Section title="Pie chart" subtitle="Sample berth status mix.">
        <PieChart data={SAMPLE_PIE} innerRadiusRatio={0.5} />
      </Section>
      <Section title="Table" subtitle="Recent sample events.">
        <DataTable<SampleRow>
          columns={[
            { header: 'Date', flex: 1, render: (r) => r.date },
            { header: 'Action', flex: 2, render: (r) => r.action },
            { header: 'Who', flex: 1, render: (r) => r.who },
          ]}
          rows={SAMPLE_ROWS}
        />
      </Section>
    </DocumentShell>
  );
}
