import { Link } from "react-router-dom"; import { Skeleton } from "@/components/ui/skeleton"; import { fmt } from "@/lib/format"; import { usePayerSummary } from "@/hooks/usePayerSummary"; import type { PayerSummary } from "@/lib/api"; interface Props { payerId: string; } /** * Peek body for a payer — aggregate stats card shown inside the * centered PeekModal (SP21 universal drill-down). * * Owns its own fetch via `usePayerSummary`; the parent PeekModal only * concerns itself with open/close + title. We deliberately do NOT show * an error state here — the peek is a low-stakes summary, so a silent * retry + skeleton on failure is acceptable (the parent modal still * closes correctly). * * `fmt.pct` does not multiply by 100 (it's just `n.toFixed(d)%`), so the * API's fraction `denial_rate` (0–1) needs `* 100` before formatting — * otherwise the UI would render "0.0%" for everything. */ export function PayerPeekContent({ payerId }: Props) { const { data, isLoading } = usePayerSummary(payerId); if (isLoading || !data) { return (
); } return ; } function Loaded({ payer }: { payer: PayerSummary }) { return (
{payer.name}
{payer.payer_id}
{payer.top_providers.length > 0 ? (
Top providers
    {payer.top_providers.slice(0, 3).map((p) => (
  • {p.npi} {fmt.num(p.count)} claims
  • ))}
) : null} View all claims →
); } function Stat({ label, value, accent, }: { label: string; value: string; accent?: "accent" | "success" | "warning"; }) { const color = accent === "success" ? "text-[hsl(var(--success))]" : accent === "warning" ? "text-[hsl(var(--warning))]" : accent === "accent" ? "text-accent" : "text-foreground"; return (
{label}
{value}
); }