"use client"; import { useState } from "react"; import type { ConfidenceLabel, Finding, InferredProject, ReportResponse } from "@/lib/types"; import { formatDateTime } from "@/lib/format"; const CONFIDENCE_LABELS: Record = { confirmed: "Confirmed", strongly_indicated: "Strongly indicated", likely: "Likely", possible: "Possible", unconfirmed: "Unconfirmed", insufficient_evidence: "Insufficient evidence", }; const CONFIDENCE_CLASSES: Record = { confirmed: "bg-green-100 text-green-800", strongly_indicated: "bg-green-50 text-green-700", likely: "bg-amber-100 text-amber-800", possible: "bg-amber-50 text-amber-700", unconfirmed: "bg-slate-100 text-slate-600", insufficient_evidence: "bg-slate-100 text-slate-500", }; function ConfidenceBadge({ confidence }: { confidence: ConfidenceLabel }) { return ( {CONFIDENCE_LABELS[confidence]} ); } function Section({ number, title, children, }: { number: number; title: string; children: React.ReactNode; }) { return (

{number}. {title}

{children}
); } function FindingList({ findings }: { findings: Finding[] }) { if (findings.length === 0) { return (

No findings for this section from the current evidence.

); } return ( ); } function ProjectList({ projects }: { projects: InferredProject[] }) { if (projects.length === 0) { return (

No inferred strategic projects from the current evidence.

); } return ( ); } function StringList({ items, emptyText }: { items: string[]; emptyText: string }) { if (items.length === 0) return

{emptyText}

; return ( ); } export function ReportView({ report }: { report: ReportResponse }) { const [copied, setCopied] = useState(false); const c = report.structured_report; const handleCopy = async () => { await navigator.clipboard.writeText(JSON.stringify(c, null, 2)); setCopied(true); setTimeout(() => setCopied(false), 2000); }; const downloadJson = () => { const blob = new Blob([JSON.stringify(c, null, 2)], { type: "application/json" }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = `${report.title}.json`; a.click(); URL.revokeObjectURL(url); }; return (

{report.title}

{report.report_type} report · generated {formatDateTime(report.created_at)} ·{" "} {report.model_provider}/{report.model_name}

{c.executive_summary}

{c.company_overview}

{c.market_positioning}

{c.competitor_comparison}

Strengths

Weaknesses

Opportunities

Threats

{c.customer_sentiment}

Risks

Opportunities

{c.methodology}

{c.limitations}

); }