import { ArrowLeft, CheckCircle2, MapPin, Printer } from 'lucide-react' import { Link, useLocation, useParams } from 'react-router-dom' import { SeverityLabel, StatusBadge } from '../components/Badges' import { ActionsSection } from '../components/incident/ActionsSection' import { ActivitySection } from '../components/incident/ActivitySection' import { AttachmentsSection } from '../components/incident/AttachmentsSection' import { DetailsSection } from '../components/incident/DetailsSection' import { InvestigationSection } from '../components/incident/InvestigationSection' import { WorkflowPanel } from '../components/incident/WorkflowPanel' import { Page } from '../components/Page' import { ErrorMessage, Loading } from '../components/QueryState' import { secondaryButton } from '../components/styles' import { ApiError } from '../lib/api' import { formatDateTime } from '../lib/dates' import { incidentTypeLabel } from '../lib/labels' import { useIncident } from '../lib/queries' export function IncidentDetail() { const number = Number(useParams().number) const location = useLocation() const query = useIncident(number) const incident = query.data if (query.isPending) return if (!incident) { return ( {query.error instanceof ApiError && query.error.status === 404 ? (

This incident doesn’t exist or you don’t have access to it.{' '} Back to incidents

) : ( )}
) } const justReported = (location.state as { justReported?: boolean } | null)?.justReported return ( All incidents {justReported && (
Thanks, {incident.reference} has been reported. The safety team has been notified{incident.severity === 'high' || incident.severity === 'critical' ? ' straight away' : ''}.
)}
{incident.reference} · {incidentTypeLabel[incident.type]}

{incident.title}

{[incident.site.name, incident.area?.name].filter(Boolean).join(' · ')} Occurred {formatDateTime(incident.occurredAt)} Reported by {incident.anonymous ? 'anonymous' : (incident.reporter?.name ?? incident.reporterName ?? 'former user')} {incident.kiosk && ` via ${incident.kiosk.name}`} · {formatDateTime(incident.reportedAt)}
) }