// ===== ROAD HAZARD REPORT ===== // Community reporting for road & sidewalk hazards, anchored by the // "Ibalik ang Sidewalk sa mga Tao" campaign (clear sidewalks for pedestrians). const hazard_types = [ { id: 'vendor', label: 'Illegal vendor on sidewalk', icon: 'π', campaign: true }, { id: 'parking', label: 'Vehicle on sidewalk', icon: 'π', campaign: true }, { id: 'structure', label: 'Structure blocking sidewalk', icon: 'ποΈ', campaign: true }, { id: 'pothole', label: 'Pothole / road damage', icon: 'π³οΈ', campaign: false }, { id: 'flood', label: 'Flooding', icon: 'π', campaign: false }, { id: 'debris', label: 'Debris / obstruction', icon: 'πͺ¨', campaign: false }, { id: 'light', label: 'Broken light / signal', icon: 'π‘', campaign: false }, { id: 'drain', label: 'Open manhole / drainage', icon: 'β οΈ', campaign: false }, { id: 'tree', label: 'Fallen tree / branch', icon: 'π³', campaign: false }, ]; const hazard_recent = [ { id: 1, type: 'Vehicle on sidewalk', icon: 'π', loc: 'Aurora Blvd, Cubao', time: '20 min ago', status: 'Forwarded to LGU', color: '#2556a8' }, { id: 2, type: 'Pothole', icon: 'π³οΈ', loc: 'Commonwealth Ave, QC', time: '1 hr ago', status: 'Under review', color: '#ffa502' }, { id: 3, type: 'Illegal vendor on sidewalk', icon: 'π', loc: 'Divisoria, Manila', time: '3 hrs ago', status: 'Resolved', color: '#00c48c' }, ]; function RoadHazardScreen({ t, go, user }) { const now = new Date(); const isoDate = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 10); const isoTime = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(11, 16); const [type, setType] = useState(''); const [photo, setPhoto] = useState(null); // {url} const [video, setVideo] = useState(null); // {name} const [loc, setLoc] = useState(''); const [date, setDate] = useState(isoDate); const [time, setTime] = useState(isoTime); const [desc, setDesc] = useState(''); const [submitted, setSubmitted] = useState(null); const photoRef = useRef(null); const videoRef = useRef(null); const ready = type && loc.trim() && (photo || video); const onPhoto = (e) => { const f = e.target.files && e.target.files[0]; if (f) setPhoto({ url: URL.createObjectURL(f), name: f.name }); }; const onVideo = (e) => { const f = e.target.files && e.target.files[0]; if (f) setVideo({ url: URL.createObjectURL(f), name: f.name }); }; const useGps = () => setLoc(`${(14.55 + Math.random() * 0.2).toFixed(4)}Β° N, ${(120.95 + Math.random() * 0.12).toFixed(4)}Β° E`); const submit = () => { if (!ready) return; setSubmitted({ ref: 'HZ-' + Math.floor(100000 + Math.random() * 900000), type: hazard_types.find(h => h.id === type)?.label }); }; const reset = () => { setSubmitted(null); setType(''); setPhoto(null); setVideo(null); setLoc(''); setDesc(''); setDate(isoDate); setTime(isoTime); }; const field = { width: '100%', border: `1.5px solid ${t.border}`, background: t.inputBg, color: t.text, borderRadius: 12, padding: '12px 13px', outline: 'none', fontWeight: 500, fontSize: 14 }; const lbl = { fontSize: 12, fontWeight: 700, color: t.text, display: 'block', marginBottom: 7 }; if (submitted) { return (
Your report of {submitted.type} has been forwarded to the concerned LGU. Ref {submitted.ref}.