+ {incident.trucks && (
+
+ )}
diff --git a/components/incidents/incident-filters.tsx b/components/incidents/incident-filters.tsx
index 06658f1..b8f1fb0 100644
--- a/components/incidents/incident-filters.tsx
+++ b/components/incidents/incident-filters.tsx
@@ -17,21 +17,23 @@ const TYPE_OPTIONS = [
{ value: '', label: 'All Types' },
{ value: 'injury', label: 'Injury' },
{ value: 'near_miss', label: 'Near Miss' },
- { value: 'dangerous_occurrence', label: 'Dangerous Occurrence' },
- { value: 'occupational_disease', label: 'Occupational Disease' },
+ { value: 'hazard', label: 'Hazard' },
+ { value: 'asset_damage', label: 'Asset Damage' },
{ value: 'environmental', label: 'Environmental' },
- { value: 'mhe_asset', label: 'MHE / Asset' },
{ value: 'security', label: 'Security' },
{ value: 'fire', label: 'Fire' },
+ { value: 'transport', label: 'Transport' },
]
export interface SiteOption { id: string; name: string }
+export interface TruckOption { id: string; truck_no: string }
interface FiltersProps {
sites: SiteOption[]
+ trucks: TruckOption[]
}
-function FiltersInner({ sites }: FiltersProps) {
+function FiltersInner({ sites, trucks }: FiltersProps) {
const router = useRouter()
const pathname = usePathname()
const searchParams = useSearchParams()
@@ -58,7 +60,7 @@ function FiltersInner({ sites }: FiltersProps) {
}, [updateParam])
const hasFilters = searchParams.get('q') || searchParams.get('status') ||
- searchParams.get('type') || searchParams.get('site_id')
+ searchParams.get('type') || searchParams.get('site_id') || searchParams.get('truck_id')
return (
@@ -102,6 +104,16 @@ function FiltersInner({ sites }: FiltersProps) {
{sites.map(s => )}
)}
+ {trucks.length > 0 && (
+
+ )}
{hasFilters && (
diff --git a/components/incidents/report-form.tsx b/components/incidents/report-form.tsx
index f114e1a..1e481d7 100644
--- a/components/incidents/report-form.tsx
+++ b/components/incidents/report-form.tsx
@@ -10,9 +10,10 @@ interface Props {
zoneToken: string | null
zoneName: string | null
siteName: string | null
+ trucks: Array<{ id: string; truck_no: string; carrier: string | null }>
}
-export function ReportForm({ zoneToken }: Props) {
+export function ReportForm({ zoneToken, trucks }: Props) {
const router = useRouter()
const t = useTranslations('ReportForm')
const itLabels = useTranslations('IncidentType')
@@ -27,6 +28,7 @@ export function ReportForm({ zoneToken }: Props) {
['environmental', itLabels.environmental],
['security', itLabels.security],
['fire', itLabels.fire],
+ ['transport', itLabels.transport],
]
const MEDICAL_STATUS_OPTIONS: [MedicalStatus, string][] = [
@@ -55,6 +57,7 @@ export function ReportForm({ zoneToken }: Props) {
injury_involved: false,
medical_status: '' as MedicalStatus | '',
asset_involved: false,
+ truck_id: '',
})
const [typeDetails, setTypeDetails] = useState>({})
@@ -116,6 +119,7 @@ export function ReportForm({ zoneToken }: Props) {
asset_involved: form.asset_involved,
medical_status: form.medical_status || undefined,
type_details: Object.keys(typeDetails).length > 0 ? typeDetails : undefined,
+ truck_id: form.truck_id || undefined,
created_at: new Date().toISOString(),
})
setSavedOffline(true)
@@ -168,6 +172,7 @@ export function ReportForm({ zoneToken }: Props) {
if (Object.keys(typeDetails).length > 0) {
fd.append('type_details', JSON.stringify(typeDetails))
}
+ if (form.truck_id) fd.append('truck_id', form.truck_id)
files.forEach(f => fd.append('files', f))
const res = await fetch('/ims/api/incidents', { method: 'POST', body: fd })
@@ -217,7 +222,7 @@ export function ReportForm({ zoneToken }: Props) {
className="w-full border border-gray-300 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
value={form.incident_type}
onChange={e => {
- setForm(f => ({ ...f, incident_type: e.target.value as IncidentType }))
+ setForm(f => ({ ...f, incident_type: e.target.value as IncidentType, truck_id: '' }))
setTypeDetails({})
}}
>
@@ -254,6 +259,27 @@ export function ReportForm({ zoneToken }: Props) {
)}
+ {form.incident_type === 'transport' && (
+
+
+
+
+ )}
+