import { WarningCircleIcon } from "@refs/design-system/icons";
import type { DecisionRecord } from "@refs/protocol";
export interface DecisionPicks {
readonly challenge: (assumption: string) => void;
readonly takePath: (name: string) => void;
}
function Section({ title, children }: { title: string; children: React.ReactNode }) {
return (
);
}
function Pick({ label, onPick }: { label: string; onPick: () => void }) {
return (
);
}
function basename(path: string): string {
return path.split("/").filter(Boolean).pop() ?? path;
}
export function DecisionView({ record, picks, muted = false }: { record: DecisionRecord; picks?: DecisionPicks; muted?: boolean }) {
const notTaken = [...new Set([...record.alternativesConsidered, ...Object.keys(record.rejected)])];
return (
{record.decision}
{record.reason.length > 0 && (
{record.reason.map((reason) => (
-
{reason}
))}
)}
{record.toReverse && (
)}
{notTaken.length > 0 && (
-
Chosen
{notTaken.map((name, index) => (
-
{name}
{record.rejected[name] && {record.rejected[name]}}
{picks && picks.takePath(name)} />}
))}
)}
{record.assumptions.length > 0 && (
{record.assumptions.map((assumption) => (
-
{assumption}
{picks && picks.challenge(assumption)} />}
))}
)}
{record.affectedComponents.length > 0 && (
{record.affectedComponents.map((path) => (
-
{basename(path)}
))}
)}
{record.evidence.length > 0 && (
Evidence ยท {record.evidence.length}
{record.evidence.map((item) => - {item}
)}
)}
);
}