import { useState } from "react"; import { ChevronDown } from "lucide-react"; import { Link, useCaseHref } from "@/lib/router"; import type { CaseSummary } from "@/api/cases"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { StatusBadge } from "@/components/StatusBadge"; import { CaseCopyableToken } from "@/components/CaseIdentifierKey"; type CaseRelationRow = Pick & { key?: string | null; }; /** * Children tree (P4 §3): the parent's direct child cases with type + status * chips. Display only — no rollup semantics. Renders nothing structural beyond * a flat list; nesting depth is intentionally one level in v1. */ export function CaseChildrenTree({ children, maxVisible, }: { children: CaseRelationRow[]; maxVisible?: number; }) { const caseHref = useCaseHref(); const [expanded, setExpanded] = useState(false); if (children.length === 0) { return

No child cases.

; } const shouldCap = maxVisible != null && children.length > maxVisible; const visibleChildren = shouldCap && !expanded ? children.slice(0, maxVisible) : children; const hiddenCount = children.length - visibleChildren.length; return (
{hiddenCount > 0 ? ( ) : null}
); }