'use client' import { useState } from 'react' import { usePDF } from 'react-to-pdf' import type { ChiefAnalystReport } from '@/lib/types/agents' import type { StepStatus } from '@/lib/types/agents' type Props = { report: ChiefAnalystReport | null status: StepStatus ticker: string date: string } const VERDICT_COLOR: Record = { BUY: 'var(--buy)', SELL: 'var(--sell)', HOLD: 'var(--hold)', } export default function ChiefAnalystCard({ report, status, ticker, date }: Props) { const [pdfError, setPdfError] = useState(false) const { toPDF, targetRef } = usePDF({ filename: `${ticker}-${date}-chief-analyst-report.pdf` }) const handleDownload = () => { setPdfError(false) try { toPDF() } catch { setPdfError(true) } } return (
{/* Header */}
Chief Analyst — Executive Summary
{status === 'done' && report && (
{pdfError && ( PDF failed — try again )}
)}
{/* Body */} {status === 'pending' && (
Chief Analyst is standing by…
)} {status === 'running' && (
{[40, 70, 55, 80].map((w, i) => (
))}
)} {status === 'done' && !report && (
Report unavailable for this run.
)} {status === 'done' && report && (
{/* Top row: Verdict + Catalyst */}
{/* Verdict badge */}
Verdict
{report.verdict}
{/* Catalyst */}
Catalyst

{report.catalyst}

{/* Divider */}
{/* Execution */}
Execution

{report.execution}

{/* Divider */}
{/* Tail Risk */}
Tail Risk

{report.tail_risk}

)}
) }