"use client"; import type { Case } from "@/lib/api/cases"; import { phaseOf, type PhaseKey } from "@/lib/api/case-status"; import { STATUS_LABELS } from "@/components/cases/status-badge"; /* * Conic-gradient donut — ported from legal-ai/web/static/index.html renderHero(). * Kept deliberately dependency-free (no D3/recharts) — a single background-image. * Five status groups (= the SSoT phases) map onto navy/gold/info/warn/success. */ type GroupKey = PhaseKey; const GROUP_META: Record = { intake: { label: "חדש / בעיבוד", color: "var(--color-ink-muted)" }, prep: { label: "הכנה", color: "var(--color-info)" }, thinking: { label: "ניתוח וכיוון", color: "var(--color-gold)" }, writing: { label: "בכתיבה", color: "var(--color-warn)" }, done: { label: "מוכן", color: "var(--color-success)" }, }; export function StatusDonut({ cases }: { cases?: Case[] }) { const counts: Record = { intake: 0, prep: 0, thinking: 0, writing: 0, done: 0, }; (cases ?? []).forEach((c) => { const g = phaseOf(c.status); if (g) counts[g] += 1; }); const total = Object.values(counts).reduce((a, b) => a + b, 0); const segments: { key: GroupKey; start: number; end: number }[] = []; let pct = 0; (Object.keys(counts) as GroupKey[]).forEach((k) => { if (counts[k] === 0) return; const start = total === 0 ? 0 : (pct / total) * 360; pct += counts[k]; const end = total === 0 ? 360 : (pct / total) * 360; segments.push({ key: k, start, end }); }); const background = total === 0 ? "conic-gradient(var(--color-rule-soft) 0deg 360deg)" : `conic-gradient(${segments .map((s) => `${GROUP_META[s.key].color} ${s.start}deg ${s.end}deg`) .join(", ")})`; return (
{total} תיקים
    {(Object.keys(GROUP_META) as GroupKey[]).map((k) => (
  • {GROUP_META[k].label} {counts[k]}
  • ))}
); } /* Exported for the legend tests / docs if ever needed */ export { STATUS_LABELS };