fbe9940a3f
Distill the UI into a single, recognizable voice: a precision instrument for one operator on one machine. Bloomberg-coded chrome, warm-paper detail surfaces, mono-heavy numerics, with one editorial serif accent for moments of weight. Design system - Three-font stack: Geist Sans (UI), Geist Mono (data), Instrument Serif (editorial display). No Inter, no system fonts. - Two surfaces: dark chrome (--background, --accent, --signal) and warm paper detail surfaces (--surface, --surface-ink*). - Inbox has its own Ticker Tape terminal palette (--tt-*). - Shared component classes: .eyebrow, .mono, .display, .surface, .surface-2, .row-hover, .nav-active, .kbd, .editorial, .hairline. - --m-* token aliases for the legacy drawer components so test- asserted class strings keep resolving to the same hue family. Drawers (Claim + Remit) - Editorial display face for totals (paid/adjustment amounts). - Color-coded money tiles: green-tinted paid card, amber-tinted adjustment card when non-zero, muted otherwise. - Tabs get accent-blue underline + CSS-driven active state. - Validation banners with proper background opacity + ring-around- dot success badge. - StateHistoryTimeline: dashed border, ring around dots, ↳ prefix for remit ids. - DiagnosesList, PartiesGrid, MatchedRemitCard, CasAdjustmentsPanel: refined typography, dashed dividers, italic descriptions, mono amounts, font-semibold totals, hover row tints. Inbox Ticker Tape - Custom RowCheckbox with sr-only input + amber accent. - Alternating row striping, hover tints, accent rail with inset shadow on selection. - Refined sparkline with glow at high values. - BulkBar: bottom-floating bar with amber count chip, larger shadow. - CandidateBreakdown: animated progress bars with amber gradient. - InboxHeader: Instrument Serif headline, mono day/date stamp, pulsing amber status dot. Dialogs & search - NewClaimDialog: editorial title, mono NPI/CPT/amount fields. - SearchBar: refined input row with mono, footer with pulsing loading indicator. - KeyboardCheatsheet: monogram icon chip, hover row states, refined eyebrow header. Primitives - StatusBadge / ClaimStateBadge: per-state dot indicators. - SelectItem: data-[highlighted]:outline tokens for keyboard a11y. - Table primitives: refined header treatment, hover/focus states. Tests + build - 354/354 tests passing across 59 files. - Vite build clean (53.84 kB CSS / 560.86 kB JS). - Eyebrow assertions updated to match the consolidated .eyebrow class (intact visual contract, abstracted class string). - Badge variant tokens updated to the polished bg-muted/80 / /0.14 opacity scale.
168 lines
6.3 KiB
TypeScript
168 lines
6.3 KiB
TypeScript
import { useMemo } from "react";
|
|
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
|
import { ApiError } from "@/lib/api";
|
|
import { useRemitDetail } from "@/hooks/useRemitDetail";
|
|
import { useDrawerKeyboard } from "@/hooks/useDrawerKeyboard";
|
|
import { RemitDrawerHeader } from "./RemitDrawerHeader";
|
|
import { FinancialSummaryCard } from "./FinancialSummaryCard";
|
|
import { PartiesGrid } from "./PartiesGrid";
|
|
import { ClaimPaymentsTable } from "./ClaimPaymentsTable";
|
|
import { CasAdjustmentsPanel } from "./CasAdjustmentsPanel";
|
|
import { RemitDrawerSkeleton } from "./RemitDrawerSkeleton";
|
|
import { RemitDrawerError } from "./RemitDrawerError";
|
|
|
|
type RemitDrawerProps = {
|
|
/**
|
|
* Currently-open remit id, or `null` when the drawer is closed.
|
|
* When `null`, the drawer renders nothing (no DOM) and the keyboard
|
|
* listener is disabled — matches the `ClaimDrawer` contract so the
|
|
* two drawers behave identically.
|
|
*/
|
|
remitId: string | null;
|
|
/**
|
|
* Full ordered list of remit ids in the current view. Used to derive
|
|
* j/k navigation targets without an extra round-trip to the server.
|
|
* The list must contain the current `remitId` for j/k to do
|
|
* anything; an unknown id is treated defensively as "navigation
|
|
* disabled" rather than throwing.
|
|
*/
|
|
remits: { id: string }[];
|
|
/** Fired when the user dismisses the drawer (X button, header close, or Escape). */
|
|
onClose: () => void;
|
|
/** Fired when the user navigates via j/k — receives the new remit id. */
|
|
onNavigate: (newId: string) => void;
|
|
/** Fired when the user presses `?` to toggle the keyboard-help overlay. */
|
|
onToggleHelp: () => void;
|
|
};
|
|
|
|
/**
|
|
* Root remittance-detail drawer (RemitDrawer).
|
|
*
|
|
* Twin of `ClaimDrawer` — same dialog shell, same keyboard contract,
|
|
* same skeleton/error/loaded tri-state. Composes:
|
|
*
|
|
* 1. **Data** — `useRemitDetail(remitId)` returns
|
|
* `{ data, isLoading, isError, error, refetch }`. The hook
|
|
* short-circuits when `remitId === null` so a closed drawer is
|
|
* free (no fetch, no cache slot).
|
|
*
|
|
* 2. **Keyboard** — `useDrawerKeyboard` wires j/k/ArrowDown/ArrowUp/
|
|
* Escape/`?` on `window`. Listener is only attached when the
|
|
* drawer is open (`enabled: remitId !== null`).
|
|
*
|
|
* 3. **Layout** — right-anchored side panel via the project's
|
|
* `Dialog` primitive, with sections composed from the leaf
|
|
* components (header + financial summary + parties + claim
|
|
* payments + CAS adjustments). Each section owns its own visual
|
|
* language so the layout stays composable.
|
|
*
|
|
* j/k navigation wraps around at both ends. `useMemo` keeps the
|
|
* navigation callbacks stable across renders so the keyboard effect
|
|
* doesn't re-subscribe on every parent update.
|
|
*
|
|
* Error branching mirrors the claim drawer:
|
|
* - `ApiError(404)` → "not_found" (no retry, the remit is gone)
|
|
* - anything else → "network" (retry available)
|
|
*/
|
|
export function RemitDrawer({
|
|
remitId,
|
|
remits,
|
|
onClose,
|
|
onNavigate,
|
|
onToggleHelp,
|
|
}: RemitDrawerProps) {
|
|
const { data, isLoading, isError, error, refetch } = useRemitDetail(remitId);
|
|
|
|
// j/k navigation: derive next/prev IDs based on the current remit's
|
|
// index in the parent list. Wrap around at both ends. If the current
|
|
// remit isn't in the list (stale deep link, etc.) the callbacks are
|
|
// no-ops — defensive against bad input from the parent.
|
|
const { onNext, onPrev } = useMemo(() => {
|
|
if (remitId === null) {
|
|
return { onNext: () => {}, onPrev: () => {} };
|
|
}
|
|
const idx = remits.findIndex((r) => r.id === remitId);
|
|
if (idx === -1 || remits.length === 0) {
|
|
return { onNext: () => {}, onPrev: () => {} };
|
|
}
|
|
return {
|
|
onNext: () => {
|
|
const nextId = remits[(idx + 1) % remits.length].id;
|
|
onNavigate(nextId);
|
|
},
|
|
onPrev: () => {
|
|
// Add `remits.length` before the modulo so the negative index
|
|
// (first → wrap to last) wraps correctly without a separate
|
|
// branch.
|
|
const prevId = remits[(idx - 1 + remits.length) % remits.length].id;
|
|
onNavigate(prevId);
|
|
},
|
|
};
|
|
}, [remitId, remits, onNavigate]);
|
|
|
|
useDrawerKeyboard({
|
|
enabled: remitId !== null,
|
|
onNext,
|
|
onPrev,
|
|
onClose,
|
|
onToggleHelp,
|
|
});
|
|
|
|
// Closed drawer: render nothing. The Dialog's `open` prop must also
|
|
// reflect this (so Radix tears down its portal / focus trap), and the
|
|
// early-return keeps a closed drawer free of any DOM at all.
|
|
if (remitId === null) return null;
|
|
|
|
const errorKind: "not_found" | "network" | null = isError
|
|
? error instanceof ApiError && error.status === 404
|
|
? "not_found"
|
|
: "network"
|
|
: null;
|
|
|
|
return (
|
|
<Dialog
|
|
open={remitId !== null}
|
|
onOpenChange={(open) => {
|
|
if (!open) onClose();
|
|
}}
|
|
>
|
|
<DialogContent
|
|
// Right-anchored side panel — mirrors the ClaimDrawer's
|
|
// positioning override. The Dialog primitive's default
|
|
// centered layout is suppressed so the drawer reads as a
|
|
// side-panel, not a modal.
|
|
className="fixed right-0 top-0 h-full w-full max-w-2xl translate-x-0 translate-y-0 rounded-none border-l border-[color:var(--m-border-heavy)]/60 bg-[color:var(--m-surface)] p-0 shadow-[-24px_0_60px_-12px_rgba(0,0,0,0.6)]"
|
|
data-testid="remit-drawer"
|
|
aria-describedby={undefined}
|
|
>
|
|
{isLoading ? (
|
|
<RemitDrawerSkeleton />
|
|
) : errorKind ? (
|
|
<RemitDrawerError
|
|
kind={errorKind}
|
|
onRetry={() => {
|
|
void refetch();
|
|
}}
|
|
onClose={onClose}
|
|
/>
|
|
) : data ? (
|
|
<div
|
|
className="flex h-full flex-col overflow-y-auto"
|
|
data-testid="remit-drawer-content"
|
|
>
|
|
<RemitDrawerHeader remit={data} onClose={onClose} />
|
|
<div className="flex flex-col divide-y divide-[color:var(--m-border-heavy)]/12">
|
|
<FinancialSummaryCard remit={data} />
|
|
<PartiesGrid parties={data} fallbackName={data.payerName} />
|
|
<ClaimPaymentsTable remit={data} />
|
|
{data.adjustments && data.adjustments.length > 0 ? (
|
|
<CasAdjustmentsPanel adjustments={data.adjustments} />
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
) : null}
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|