Files
cyclone/src/components/ClaimDrawer/ValidationPanel.tsx
T
Tyler fbe9940a3f feat(ui): cohesive frontend polish — design system + per-screen refinement
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.
2026-06-20 22:27:01 -06:00

191 lines
6.0 KiB
TypeScript

import { AlertCircle, AlertTriangle, CheckCircle2 } from "lucide-react";
import type { ClaimDetail } from "@/types";
type ValidationPanelProps = {
validation: ClaimDetail["validation"];
};
type IssueList = ClaimDetail["validation"]["errors"];
/**
* Group issues by their `rule` field, preserving insertion order so the
* backend's surface order is respected on screen. Returns an array of
* `[rule, issues]` pairs — Maps aren't a great fit for JSX iteration here.
*/
function groupByRule(issues: IssueList): Array<[string, IssueList]> {
const groups = new Map<string, IssueList>();
for (const issue of issues) {
const bucket = groups.get(issue.rule);
if (bucket) {
bucket.push(issue);
} else {
groups.set(issue.rule, [issue]);
}
}
return Array.from(groups.entries());
}
/**
* One rule-group block: header with rule code + count chip, followed by
* the list of messages underneath.
*/
function IssueGroup({
rule,
issues,
testId,
}: {
rule: string;
issues: IssueList;
testId: string;
}) {
const Icon = testId === "validation-errors" ? AlertCircle : AlertTriangle;
const iconColor =
testId === "validation-errors"
? "text-[color:var(--m-error)]"
: "text-[color:var(--m-warning)]";
return (
<div className="flex flex-col gap-1.5">
<div className="flex items-center gap-2">
<span
className="mono text-[12px] font-semibold tracking-tight text-[color:var(--m-ink-primary)]"
>
{rule}
</span>
<span
className="inline-flex items-center rounded-full bg-[color:var(--m-ink-tertiary)]/15 px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--m-ink-secondary)] tabular-nums"
data-testid={`${testId}-count`}
>
{issues.length}
</span>
</div>
<ul className="flex flex-col gap-1.5 pl-1">
{issues.map((issue, idx) => (
<li
key={`${rule}-${idx}`}
className="flex items-start gap-2 text-[13px] leading-snug text-[color:var(--m-ink-secondary)]"
data-testid={`${testId}-message`}
>
<Icon
className={`mt-0.5 h-3.5 w-3.5 shrink-0 ${iconColor}`}
strokeWidth={1.75}
aria-hidden
/>
<span>{issue.message}</span>
</li>
))}
</ul>
</div>
);
}
/**
* Validation section of the claim detail drawer (SP4).
*
* Three states:
* - passed && warnings.length === 0 → "All checks passed" pill
* - errors and/or warnings present → grouped sub-sections
*
* Issues are grouped by their `rule` field (e.g. R050_diagnosis_present)
* with a per-group count, so repeated violations of the same rule don't
* drown out other rules. Errors render before warnings so the user sees
* blocking issues first.
*/
export function ValidationPanel({ validation }: ValidationPanelProps) {
const allPassed = validation.passed && validation.warnings.length === 0;
if (allPassed) {
return (
<section
data-testid="validation-passed"
className="flex items-center gap-2 px-6 py-3"
>
<CheckCircle2
className="h-4 w-4 text-[color:var(--m-success)]"
strokeWidth={1.75}
aria-hidden
/>
<span className="text-[13px] font-medium text-[color:var(--m-ink-primary)]">
All checks passed
</span>
<span className="ml-auto inline-flex items-center rounded-full bg-[color:var(--m-success)]/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-[color:var(--m-success)]">
Valid
</span>
</section>
);
}
const errorGroups = groupByRule(validation.errors);
const warningGroups = groupByRule(validation.warnings);
return (
<section
className="flex flex-col gap-4 px-6 py-4 bg-[color:var(--m-surface)]"
data-testid="validation-panel"
>
<span className="eyebrow text-[color:var(--m-ink-tertiary)]">
Validation
</span>
{validation.errors.length > 0 ? (
<div
data-testid="validation-errors"
data-rule-group="errors"
role="alert"
className="flex flex-col gap-3 border-l-2 border-[color:var(--m-error)] bg-[hsl(var(--destructive)/0.06)] px-3.5 py-3"
>
<div className="flex items-center gap-2">
<AlertCircle
className="h-3.5 w-3.5 text-[color:var(--m-error)]"
strokeWidth={1.75}
aria-hidden
/>
<span className="text-[10.5px] font-semibold uppercase tracking-[0.14em] text-[color:var(--m-error)]">
Errors ({validation.errors.length})
</span>
</div>
<div className="flex flex-col gap-3">
{errorGroups.map(([rule, issues]) => (
<IssueGroup
key={rule}
rule={rule}
issues={issues}
testId="validation-errors"
/>
))}
</div>
</div>
) : null}
{validation.warnings.length > 0 ? (
<div
data-testid="validation-warnings"
data-rule-group="warnings"
className="flex flex-col gap-3 border-l-2 border-[color:var(--m-warning)] bg-[hsl(var(--warning)/0.08)] px-3.5 py-3"
>
<div className="flex items-center gap-2">
<AlertTriangle
className="h-3.5 w-3.5 text-[color:var(--m-warning)]"
strokeWidth={1.75}
aria-hidden
/>
<span className="text-[10.5px] font-semibold uppercase tracking-[0.14em] text-[color:var(--m-warning)]">
Warnings ({validation.warnings.length})
</span>
</div>
<div className="flex flex-col gap-3">
{warningGroups.map(([rule, issues]) => (
<IssueGroup
key={rule}
rule={rule}
issues={issues}
testId="validation-warnings"
/>
))}
</div>
</div>
) : null}
</section>
);
}