diff --git a/app/report/page.tsx b/app/report/page.tsx index 580481a..1934f82 100644 --- a/app/report/page.tsx +++ b/app/report/page.tsx @@ -7,11 +7,11 @@ import { LanguageSwitcher } from '@/components/language-switcher' import { OfflineSync } from '@/components/incidents/offline-sync' interface Props { - searchParams: Promise<{ zone?: string }> + searchParams: Promise<{ zone?: string; truck_id?: string }> } export default async function ReportPage({ searchParams }: Props) { - const { zone } = await searchParams + const { zone, truck_id } = await searchParams const supabase = await createClient() const { data, error: authError } = await supabase.auth.getUser() @@ -58,6 +58,7 @@ export default async function ReportPage({ searchParams }: Props) { zoneName={zoneName} siteName={siteName} trucks={(trucks ?? []) as Array<{ id: string; truck_no: string; carrier: string | null }>} + initialTruckId={truck_id ?? null} /> diff --git a/components/admin/truck-manager.tsx b/components/admin/truck-manager.tsx index eb4f68f..d6ecd8c 100644 --- a/components/admin/truck-manager.tsx +++ b/components/admin/truck-manager.tsx @@ -89,16 +89,25 @@ export function TruckManager({ trucks }: Props) { ) : ( diff --git a/components/incidents/report-form.tsx b/components/incidents/report-form.tsx index 1e481d7..9a33e11 100644 --- a/components/incidents/report-form.tsx +++ b/components/incidents/report-form.tsx @@ -11,9 +11,10 @@ interface Props { zoneName: string | null siteName: string | null trucks: Array<{ id: string; truck_no: string; carrier: string | null }> + initialTruckId?: string | null } -export function ReportForm({ zoneToken, trucks }: Props) { +export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) { const router = useRouter() const t = useTranslations('ReportForm') const itLabels = useTranslations('IncidentType') @@ -52,12 +53,12 @@ export function ReportForm({ zoneToken, trucks }: Props) { const [overrideQuality, setOverrideQuality] = useState(false) const [form, setForm] = useState({ - incident_type: '' as IncidentType | '', + incident_type: (initialTruckId ? 'transport' : '') as IncidentType | '', description: '', injury_involved: false, medical_status: '' as MedicalStatus | '', asset_involved: false, - truck_id: '', + truck_id: initialTruckId ?? '', }) const [typeDetails, setTypeDetails] = useState>({})