import { ExternalLink, X } from "lucide-react"; import { Badge, type BadgeProps } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { fmt } from "@/lib/format"; import { cn } from "@/lib/utils"; import type { RemitDetail } from "@/hooks/useRemitDetail"; type RemitDrawerHeaderProps = { remit: RemitDetail; onClose: () => void; }; /** * Remittance status → Badge variant. Mirrors the list-endpoint mapping * used by `MatchedRemitCard` (received / posted / reconciled). Unknown * statuses (the type is an unconstrained string) fall back to ``muted`` * so a future backend status doesn't blow up the drawer. * * received → secondary (in-flight, not yet posted) * posted → default (brand-colored, posted to ledger) * reconciled → success (matched to claims, settled) */ const STATUS_VARIANT: Record = { received: "secondary", posted: "default", reconciled: "success", }; function badgeVariantFor(status: string): BadgeProps["variant"] { return STATUS_VARIANT[status] ?? "muted"; } /** * Header band for the remittance detail drawer (RemitDrawer). * * Mirror of `ClaimDrawerHeader` — same instrument-style eyebrow + * mono ID on the left, status badge + total paid on the right, plus a * "View raw 835" link below the ID. The close button reuses the same * `X` icon at the same position so the two drawers have visually * identical chrome. * * The "View raw 835" link points at `/api/remittances/{id}/raw` — the * backend's text/835 endpoint for inspecting the source X12 file. The * fallback (when the backend doesn't yet expose that endpoint) is the * detail JSON endpoint so the link never 404s on a misconfigured * deployment. */ export function RemitDrawerHeader({ remit, onClose }: RemitDrawerHeaderProps) { const rawLink = `/api/remittances/${encodeURIComponent(remit.id)}/raw`; return (
{/* Left: eyebrow + mono remit ID + raw link */}
Remittance {remit.id} View raw 835
{/* Right: status badge + total paid + close */}
{remit.status} {fmt.usdPrecise(remit.paidAmount)}
); }