type FiveWhyStep = { why: string; answer: string } interface Investigation { id: string method: 'five_why' | 'fishbone' | 'other' five_why_steps: FiveWhyStep[] | null fishbone_categories: Record | null findings_text: string | null root_cause_summary: string | null alcohol_test_result: string | null witness_statement_refs: string[] completed_at: string | null investigator: { name: string | null; email: string } | null } interface Props { investigation: Investigation } const METHOD_LABELS = { five_why: '5-Why Analysis', fishbone: 'Fishbone (Ishikawa)', other: 'Other Method', } export function InvestigationPanel({ investigation: inv }: Props) { const investigatorName = inv.investigator?.name ?? inv.investigator?.email ?? 'Unknown' return (

Investigation

{METHOD_LABELS[inv.method] ?? inv.method} {inv.completed_at ? 'Completed' : 'In Progress'}

Investigator: {investigatorName} {inv.completed_at && ( ยท Completed {new Date(inv.completed_at).toLocaleDateString('en-MY', { day: 'numeric', month: 'short', year: 'numeric' })} )}

{/* 5-Why steps */} {inv.method === 'five_why' && inv.five_why_steps && inv.five_why_steps.length > 0 && (

5-Why Steps

    {inv.five_why_steps.map((step, i) => (
  1. {i + 1}

    {step.why}

    {step.answer && (

    {step.answer}

    )}
  2. ))}
)} {/* Fishbone categories */} {inv.method === 'fishbone' && inv.fishbone_categories && Object.keys(inv.fishbone_categories).length > 0 && (

Fishbone Categories

{Object.entries(inv.fishbone_categories).map(([cat, val]) => (
{cat}
{val}
))}
)} {/* Findings */} {inv.findings_text && (

Findings

{inv.findings_text}

)} {/* Root cause */} {inv.root_cause_summary && (

Root Cause

{inv.root_cause_summary}

)} {/* Alcohol test */} {inv.alcohol_test_result && (

Alcohol Test Result

{inv.alcohol_test_result}

)} {/* Witness refs */} {inv.witness_statement_refs && inv.witness_statement_refs.length > 0 && (

Witness Statements

    {inv.witness_statement_refs.map((ref, i) => (
  • {ref}
  • ))}
)}
) }