Files
ims/components/incidents/incident-header.tsx

72 lines
2.2 KiB
TypeScript

'use client'
import Link from 'next/link'
import { StatusTag } from '@/components/ui/status-tag'
interface Props {
incidentId: string
referenceNo: string | null
status: string
backHref: string
canTriage?: boolean
canInvestigate?: boolean
canAddCapa?: boolean
}
const STATUS_LABELS: Record<string, string> = {
reported: 'Reported',
triaged: 'Triaged',
investigating: 'Investigating',
capa_pending: 'CAPA Pending',
verification: 'Verification',
closed: 'Closed',
}
export function IncidentHeader({
incidentId, referenceNo, status, backHref,
canTriage, canInvestigate, canAddCapa,
}: Props) {
return (
<div className="sticky top-0 z-30 bg-surface border-b border-divider shadow-sm">
<div className="max-w-3xl mx-auto px-4 py-3 flex items-center justify-between gap-4 flex-wrap">
<div className="flex items-center gap-3 min-w-0">
<Link href={backHref} className="text-sm text-gray-500 hover:text-gray-700 shrink-0">
← Incidents
</Link>
<span className="text-gray-300 shrink-0">|</span>
<span className="text-sm font-mono font-semibold text-gray-900 truncate">
{referenceNo ?? 'Pending'}
</span>
<span className="shrink-0"><StatusTag status={status}>{STATUS_LABELS[status] ?? status.replace(/_/g, ' ')}</StatusTag></span>
</div>
<div className="flex gap-2 shrink-0">
{canTriage && (
<Link
href={`/hse/incidents/${incidentId}/triage`}
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
>
Triage
</Link>
)}
{canInvestigate && (
<Link
href={`/hse/incidents/${incidentId}/investigation`}
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
>
Investigate
</Link>
)}
{canAddCapa && (
<Link
href={`/hse/incidents/${incidentId}/capa/new`}
className="text-xs px-3 py-1.5 bg-accent text-white font-medium hover:bg-accent-600"
>
Add CAPA
</Link>
)}
</div>
</div>
</div>
)
}