feat: show investigation panel on incident detail page
Fetches investigation record (5-Why steps, findings, root cause, alcohol test, witness refs) and renders below incident details. Shows completion status and investigator name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
This commit is contained in:
@@ -6,6 +6,7 @@ import { IncidentDetail, type Incident } from '@/components/incidents/incident-d
|
||||
import { IncidentHeader } from '@/components/incidents/incident-header'
|
||||
import { SimilarIncidentsPanel } from '@/components/incidents/similar-incidents-panel'
|
||||
import { ClosurePanel } from '@/components/incidents/closure-panel'
|
||||
import { InvestigationPanel } from '@/components/incidents/investigation-panel'
|
||||
|
||||
interface Props {
|
||||
params: Promise<{ id: string }>
|
||||
@@ -35,6 +36,17 @@ export default async function HseIncidentDetailPage({ params }: Props) {
|
||||
|
||||
const status = (incident as { status: string }).status
|
||||
|
||||
const { data: investigation } = await supabase
|
||||
.from('investigations')
|
||||
.select(`
|
||||
id, method, five_why_steps, fishbone_categories,
|
||||
findings_text, root_cause_summary, alcohol_test_result,
|
||||
witness_statement_refs, completed_at,
|
||||
investigator:users!investigator_id (name, email)
|
||||
`)
|
||||
.eq('incident_id', id)
|
||||
.maybeSingle()
|
||||
|
||||
const needsJkkp = Boolean(
|
||||
(incident as { is_fatality?: boolean }).is_fatality ||
|
||||
(incident as { is_serious_bodily_injury?: boolean }).is_serious_bodily_injury ||
|
||||
@@ -56,6 +68,10 @@ export default async function HseIncidentDetailPage({ params }: Props) {
|
||||
<main className="max-w-3xl mx-auto px-4 py-6">
|
||||
<IncidentDetail incident={incident as unknown as Incident} />
|
||||
|
||||
{investigation && (
|
||||
<InvestigationPanel investigation={investigation as never} />
|
||||
)}
|
||||
|
||||
{needsJkkp && (
|
||||
<div className="mt-4 flex gap-3 flex-wrap">
|
||||
<a
|
||||
|
||||
Reference in New Issue
Block a user