style(frontend): tidy drawer review nits
- RawSegmentsPanel: summary now reads 'Show N raw segments' for non-empty (with singular pluralization). The previous identical ternary branches read as a bug. - PartiesGrid: replace the verbose intersection cast on AddressBlock with a direct ClaimDetailAddress cast (the union's other arm is Record<string, never>, ruled out by isEmptyAddress above).
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import type { ClaimDetail } from "@/types";
|
import type { ClaimDetail, ClaimDetailAddress } from "@/types";
|
||||||
|
|
||||||
type PartiesGridProps = {
|
type PartiesGridProps = {
|
||||||
parties: ClaimDetail["parties"];
|
parties: ClaimDetail["parties"];
|
||||||
@@ -20,15 +20,9 @@ function isEmptyAddress(addr: AddressLike | null | undefined): boolean {
|
|||||||
|
|
||||||
function AddressBlock({ address }: { address: AddressLike }) {
|
function AddressBlock({ address }: { address: AddressLike }) {
|
||||||
if (isEmptyAddress(address)) return null;
|
if (isEmptyAddress(address)) return null;
|
||||||
// After the empty check the cast is safe; the alternative `ClaimDetailAddress`
|
// After the empty check the cast is safe — the remaining union arm is
|
||||||
// shape has all the fields we read.
|
// `ClaimDetailAddress` which has all the fields we read.
|
||||||
const a = address as ClaimDetail["parties"]["billingProvider"]["address"] & {
|
const a = address as ClaimDetailAddress;
|
||||||
line1: string;
|
|
||||||
line2: string | null;
|
|
||||||
city: string;
|
|
||||||
state: string;
|
|
||||||
zip: string;
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="text-xs leading-relaxed text-[color:var(--m-ink-secondary)]"
|
className="text-xs leading-relaxed text-[color:var(--m-ink-secondary)]"
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ export function RawSegmentsPanel({ rawSegments }: RawSegmentsPanelProps) {
|
|||||||
data-testid="raw-segments-summary"
|
data-testid="raw-segments-summary"
|
||||||
>
|
>
|
||||||
{rawSegments.length === 0
|
{rawSegments.length === 0
|
||||||
? "Show raw segments"
|
? `Show raw segments`
|
||||||
: "Show raw segments"}
|
: `Show ${rawSegments.length} raw segment${rawSegments.length === 1 ? "" : "s"}`}
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
{rawSegments.length === 0 ? (
|
{rawSegments.length === 0 ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user