import { Card, CardContent } from "@/components/ui/card"; import type { Case } from "@/lib/api/cases"; import { phaseOf } from "@/lib/api/case-status"; type Bucket = { label: string; caption: string; value: number; tone: "navy" | "gold" | "warn" | "success"; }; const TONE_STYLES: Record = { navy: "before:bg-navy text-navy", gold: "before:bg-gold text-gold-deep", warn: "before:bg-warn text-warn", success: "before:bg-success text-success", }; function bucketize(cases: Case[] | undefined): Bucket[] { const c = cases ?? []; /* Buckets derive from the SSoT phases: "בהכנה" = everything from processing * through direction-approval (intake-after-new + prep + thinking). */ const inProgress = c.filter((x) => { const p = phaseOf(x.status); return x.status === "processing" || p === "prep" || p === "thinking"; }).length; const drafting = c.filter((x) => phaseOf(x.status) === "writing").length; const done = c.filter((x) => phaseOf(x.status) === "done").length; return [ { label: "סה״כ תיקי ערר", caption: "בכל הסטטוסים", value: c.length, tone: "navy" }, { label: "בהכנה", caption: "מסמכים וניתוח", value: inProgress, tone: "gold" }, { label: "בכתיבה", caption: "טיוטות ו-QA", value: drafting, tone: "warn" }, { label: "מוכנים", caption: "יוצאו או סופיים", value: done, tone: "success" }, ]; } export function KPICards({ cases, loading }: { cases?: Case[]; loading?: boolean }) { const buckets = bucketize(cases); return (
{buckets.map((b) => ( {b.label} {loading ? "—" : b.value} {b.caption} ))}
); }