"use client"; import { BanknoteIcon } from "lucide-react"; import { isPackMissing, OrdersTable } from "@/components/commerce/orders-view"; import { EmptyState, ErrorState, PageHeader, StatTile } from "@/components/shell/page"; import { Skeleton } from "@/components/ui/skeleton"; import { formatMoney, formatNumber, formatPct } from "@/lib/format"; import { useI18n } from "@/lib/i18n"; import type { CodSummary, RiskBand } from "@/lib/types"; import { useApi } from "@/lib/use-api"; import { cn } from "@/lib/utils"; const BAND_BAR: Record = { low: "bg-success", medium: "bg-warning", high: "bg-destructive", }; export function CodView() { const { t, m, locale } = useI18n(); const s = useApi("/packs/ecommerce/cod/summary", { pollMs: 30_000 }); let body; if (s.error && isPackMissing(s.error)) { body = ; } else if (s.error && !s.data) { body = ; } else if (!s.data) { body = ; } else { const d = s.data; const bandTotal = d.by_band.low + d.by_band.medium + d.by_band.high; body = (

{t("cod.byBand")}

{(["low", "medium", "high"] as const).map((b) => d.by_band[b] ? (
) : null, )}
{(["low", "medium", "high"] as const).map((b) => (
{m.orders.bands[b]}
{formatNumber(d.by_band[b])}
))}

{t("cod.queue")}

); } return (
{body}
); }