export const dynamic = 'force-dynamic' import { notFound } from 'next/navigation' import { createClient } from '@/lib/supabase/server' import { IncidentDetail, type Incident } from '@/components/incidents/incident-detail' import { IncidentHeader } from '@/components/incidents/incident-header' import { SimilarIncidentsPanel } from '@/components/incidents/similar-incidents-panel' import { ClosurePanel } from '@/components/incidents/closure-panel' interface Props { params: Promise<{ id: string }> } export default async function HseIncidentDetailPage({ params }: Props) { const { id } = await params const supabase = await createClient() const { data: incident, error } = await supabase .from('incidents') .select(` id, reference_no, incident_type, description, severity, status, injury_involved, asset_involved, medical_status, lost_days, type_details, is_fatality, is_serious_bodily_injury, is_dangerous_occurrence, is_occupational_disease, reported_at, closed_at, sites (id, name), zones (id, name), reporter:users!reported_by (id, name, email), evidence_files (id, stage, file_url, file_type, uploaded_at) `) .eq('id', id) .eq('evidence_files.deleted', false) .single() if (error || !incident) notFound() const status = (incident as { status: string }).status const needsJkkp = Boolean( (incident as { is_fatality?: boolean }).is_fatality || (incident as { is_serious_bodily_injury?: boolean }).is_serious_bodily_injury || (incident as { is_dangerous_occurrence?: boolean }).is_dangerous_occurrence || ((incident as { lost_days?: number | null }).lost_days ?? 0) >= 4 ) return ( <>
{needsJkkp && (
Download JKKP 6 (PDF) Download JKKP 7 (PDF)
)}
) }