import { Badge } from "@/components/ui/badge"; import { ScrollArea } from "@/components/ui/scroll-area"; import type { CaseDetail } from "@/lib/api/cases"; /* * Document list for the case detail "מסמכים" tab. Uses the real document * row shape returned by the FastAPI case_get endpoint — see db.list_documents * and the `documents` schema in legal_mcp/services/db.py: * id · case_id · doc_type · title · file_path · extraction_status · * page_count · created_at · practice_area · appeal_subtype */ const DOC_TYPE_LABELS: Record = { appeal: "כתב ערר", response: "כתב תשובה", protocol: "פרוטוקול", decision: "החלטת ועדה מקומית", plan: "תכנית", reference: "חומר רקע", auto: "—", }; function doctypeLabel(t: string): string { return DOC_TYPE_LABELS[t] ?? t; } function doctypeTone(t: string): string { switch (t) { case "appeal": return "bg-info-bg text-info border-info/40"; case "response": return "bg-gold-wash text-gold-deep border-gold/40"; case "decision": return "bg-success-bg text-success border-success/40"; case "protocol": return "bg-warn-bg text-warn border-warn/40"; default: return "bg-rule-soft text-ink-muted border-rule"; } } const STATUS_LABELS: Record = { pending: "בהמתנה", processing: "בעיבוד", completed: "הושלם", proofread: "הוגה", failed: "נכשל", error: "שגיאה", }; function formatDate(iso: string) { if (!iso) return "—"; try { return new Date(iso).toLocaleDateString("he-IL"); } catch { return iso; } } function filenameFromPath(path: string): string { const parts = path.split("/"); return parts[parts.length - 1] || path; } export function DocumentsPanel({ data }: { data?: CaseDetail }) { const docs = data?.documents ?? []; if (docs.length === 0) { return (

אין מסמכים בתיק זה

); } return (
    {docs.map((doc) => { const displayName = doc.title || filenameFromPath(doc.file_path); const statusDone = doc.extraction_status === "completed" || doc.extraction_status === "proofread"; return (
  • {displayName}
    {doc.page_count != null && ( {doc.page_count} עמ׳ )} {doc.created_at && {formatDate(doc.created_at)}} {!statusDone && doc.extraction_status && ( {STATUS_LABELS[doc.extraction_status] ?? doc.extraction_status} )}
    {doc.doc_type && ( {doctypeLabel(doc.doc_type)} )}
  • ); })}
); }