import { useState } from 'react' import { Alert, Box, Button, Chip, Collapse, IconButton, Typography } from '@mui/material' import { AlertTriangle, ChevronDown, ChevronUp, Target } from 'lucide-react' import type { ReactNode } from 'react' export interface DecisionMetric { label: string value: string | number severity?: 'neutral' | 'positive' | 'warning' | 'critical' } export interface DecisionAction { label: string primary?: boolean onClick: () => void } interface Props { /** The core question this screen answers */ decision: string /** One-line explanation of why this decision matters */ context?: string /** Key data points relevant to the decision */ metrics?: DecisionMetric[] /** Missing data that could affect the decision */ missing?: string[] /** Active risks the user should be aware of */ risks?: string[] /** Available actions — first primary action is highlighted */ actions?: DecisionAction[] /** Custom content after the standard rows */ children?: ReactNode } const SEVERITY_COLOR: Record, string> = { neutral: '#f1f5f9', positive: '#f0fdf4', warning: '#fef9c3', critical: '#fef2f2', } const SEVERITY_TEXT: Record, string> = { neutral: '#475569', positive: '#1a7a4a', warning: '#92400e', critical: '#991b1b', } export function DecisionContextPanel({ decision, context, metrics = [], missing = [], risks = [], actions = [], children, }: Props) { const [expanded, setExpanded] = useState(false) const hasDetails = missing.length > 0 || risks.length > 0 || !!children return ( {/* Main row */} {/* Decision question */} {decision} {context && ( {context} )} {/* Metric chips */} {metrics.length > 0 && ( {metrics.map((m, i) => { const sev = m.severity ?? 'neutral' return ( ) })} )} {/* Actions + expand toggle */} {actions.map((a, i) => ( ))} {hasDetails && ( setExpanded(v => !v)} sx={{ color: '#64748b', width: 24, height: 24 }} > {expanded ? : } )} {/* Expandable details */} {risks.length > 0 && ( } sx={{ py: 0.25, '& .MuiAlert-message': { fontSize: '0.75rem' } }}> Risiken:{' '}{risks.join(' · ')} )} {missing.length > 0 && ( Fehlende Daten:{' '}{missing.join(' · ')} )} {children} ) }