import { Badge } from "@/components/ui/badge"; import { ClaimStateBadge } from "@/components/ui/claim-state-badge"; import type { ClaimState, ClaimStatus, RemittanceStatus } from "@/types"; import { CLAIM_STATES } from "@/types"; import { cn } from "@/lib/utils"; const claimStyles: Record = { draft: { dot: "bg-muted-foreground", label: "Draft" }, submitted: { dot: "bg-[hsl(var(--accent))]", label: "Submitted" }, accepted: { dot: "bg-[hsl(var(--success))]", label: "Accepted" }, denied: { dot: "bg-destructive", label: "Denied" }, paid: { dot: "bg-[hsl(var(--success))]", label: "Paid" }, pending: { dot: "bg-[hsl(var(--warning))]", label: "Pending" }, }; const remitStyles: Record = { received: { dot: "bg-[hsl(var(--accent))]", label: "Received" }, posted: { dot: "bg-[hsl(var(--warning))]", label: "Posted" }, reconciled: { dot: "bg-[hsl(var(--success))]", label: "Reconciled" }, }; /** * Generic status badge: delegates to `ClaimStateBadge` when the value is one * of the seven canonical `ClaimState` values from the reconciliation model, * otherwise falls back to a plain Badge with the legacy color. This is the * single entry point that pages should use; it lets the live API's 7-state * `state` field drive the visual while still tolerating legacy `status` * strings like "draft" / "pending" that aren't part of the new model. */ export function StatusBadge({ status, className, }: { status: string; className?: string; }) { if (CLAIM_STATES.includes(status as ClaimState)) { return ( ); } return ( {status} ); } export function ClaimStatusBadge({ status }: { status: ClaimStatus }) { // Forward to the canonical 7-state primitive when possible; fall back to // the legacy dot+label for the three non-ClaimState values (draft, // accepted, pending). if (CLAIM_STATES.includes(status as ClaimState)) { return ; } const s = claimStyles[status]; return ( {s.label} ); } export function RemitStatusBadge({ status }: { status: RemittanceStatus }) { if (CLAIM_STATES.includes(status as ClaimState)) { return ; } const s = remitStyles[status]; return ( {s.label} ); }