feat(admin): truck report link + pre-fill form via ?truck_id=

Scanning truck QR opens /ims/report?truck_id=<id>, which pre-selects
incident_type=transport and the truck in the form. TruckManager shows
"Report link / QR target" per truck, mirroring zones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
This commit is contained in:
2026-07-13 11:49:56 +08:00
co-authored by Claude Sonnet 4.6
parent f90bf4ed03
commit 370b985375
3 changed files with 26 additions and 15 deletions
+4 -3
View File
@@ -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<Record<string, string | boolean>>({})