"use client"; import { PHASES, phaseIndexOf, phaseOf, type CaseStatus, } from "@/lib/api/case-status"; import { StatusChanger } from "@/components/cases/status-changer"; import { StatusGuide } from "@/components/cases/status-guide"; import { AgentStatusWidget } from "@/components/cases/agent-status-widget"; import { SyncIndicator } from "@/components/cases/sync-indicator"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { expectedOutcomes } from "@/lib/schemas/case"; import { formatDate } from "@/lib/format-date"; import { Settings2, Users } from "lucide-react"; import type { CaseDetail } from "@/lib/api/cases"; /* * StatusRail — the integrated case-status strip that lives inside the parchment * band (CaseHeader), so it is visible on EVERY tab (banner "A", X17 case-detail * redesign — supersedes the overview-only StatusHero). One thin row of chips * (current phase · expected outcome · meta · agents popover · manual changer) * over the 5-phase pipeline stepper. Reuses the shared StatusChanger / StatusGuide * / AgentStatusWidget so no parallel status path is created (G2). */ const EXPECTED_OUTCOME_LABELS: Record = Object.fromEntries( expectedOutcomes.map((o) => [o.value, o.label]), ); /** Semantic colour per expected-outcome value (rejection/partial/full/none). */ const OUTCOME_TONE: Record = { rejection: "bg-danger-bg text-danger", partial_acceptance: "bg-warn-bg text-warn", full_acceptance: "bg-success-bg text-success", }; /** Horizontal RTL stepper over the 5 lifecycle phases (mockup A .stepper). */ function HorizontalStepper({ status }: { status?: CaseStatus }) { const currentIdx = phaseIndexOf(status); return (
    {PHASES.map((phase, i) => { const state = currentIdx === -1 ? "pending" : i < currentIdx ? "done" : i === currentIdx ? "now" : "pending"; const isLast = i === PHASES.length - 1; const knobTone = state === "done" ? "bg-success [box-shadow:0_0_0_1px_var(--color-success)]" : state === "now" ? "bg-gold [box-shadow:0_0_0_2px_var(--color-gold-wash),0_0_0_3px_var(--color-gold)]" : "bg-rule [box-shadow:0_0_0_1px_var(--color-rule)]"; const labelTone = state === "done" ? "text-ink-soft" : state === "now" ? "text-navy font-bold" : "text-ink-muted"; const segTone = state === "done" ? "bg-success" : "bg-rule"; return (
  1. {!isLast && ( )} {phase.label}
  2. ); })}
); } const PILL = "inline-flex items-center gap-1.5 rounded-full border border-rule bg-surface px-3 py-1 text-[0.72rem] font-semibold text-ink-soft hover:bg-parchment transition-colors"; export function StatusRail({ caseNumber, data, }: { caseNumber: string; data?: CaseDetail; }) { const status = data?.status; const phaseKey = phaseOf(status); const phaseLabel = phaseKey ? PHASES.find((p) => p.key === phaseKey)?.label : null; const outcome = data?.expected_outcome ?? ""; const outcomeLabel = outcome ? EXPECTED_OUTCOME_LABELS[outcome] ?? outcome : null; const outcomeTone = outcome ? OUTCOME_TONE[outcome] ?? "bg-warn-bg text-warn" : "bg-rule-soft text-ink-muted"; return (
{/* chip row */}
סטטוס {phaseLabel && ( כעת: {phaseLabel} )} תוצאה צפויה: {outcomeLabel ?? "טרם נקבעה"} דיון{" "} {formatDate(data?.hearing_date)} עודכן{" "} {formatDate(data?.updated_at)} סנכרון {/* agents popover */} {/* manual status changer + status guide popover */}
שינוי סטטוס ידני
{/* pipeline */}
); }