"use client"; import { useState } from "react"; import { ChevronDown, ChevronRight, RefreshCw } from "lucide-react"; import { BriefSchema } from "@/lib/types"; import { AIBriefCard } from "@/components/bills/AIBriefCard"; import { formatDate } from "@/lib/utils"; interface BriefPanelProps { briefs?: BriefSchema[] | null; } const TYPE_LABEL: Record = { amendment: "AMENDMENT", full: "FULL", }; function typeBadge(briefType?: string) { const label = TYPE_LABEL[briefType ?? ""] ?? (briefType?.toUpperCase() ?? "BRIEF"); const isAmendment = briefType === "amendment"; return ( {label} ); } export function BriefPanel({ briefs }: BriefPanelProps) { const [historyOpen, setHistoryOpen] = useState(false); const [expandedId, setExpandedId] = useState(null); if (!briefs || briefs.length === 0) { return ; } const latest = briefs[0]; const history = briefs.slice(1); const isAmendment = latest.brief_type === "amendment"; return (
{/* "What Changed" badge row */} {isAmendment && (
What Changed · {formatDate(latest.created_at)}
)} {/* Latest brief */} {/* Version history (only when there are older briefs) */} {history.length > 0 && (
{historyOpen && (
{history.map((brief) => (
{expandedId === brief.id && (
)}
))}
)}
)}
); }