"use client"; import type { Case, CaseStatus } from "@/lib/api/cases"; 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 map onto the navy/gold/info/warn/success palette. */ type GroupKey = "intake" | "prep" | "thinking" | "writing" | "done"; const GROUP_OF: Record = { new: "intake", uploading: "intake", processing: "intake", documents_ready: "prep", analyst_verified: "prep", research_complete: "prep", outcome_set: "prep", brainstorming: "thinking", direction_approved: "thinking", analysis_enriched: "thinking", ready_for_writing: "thinking", drafting: "writing", qa_review: "writing", drafted: "writing", exported: "done", reviewed: "done", final: "done", }; 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 = GROUP_OF[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 };