import { useState, useRef } from 'react'; import { motion } from 'framer-motion'; import { AlertTriangle, X, MapPin, CheckCircle } from 'lucide-react'; interface IncidentReportModalProps { onClose: () => void; onSubmit: (report: { type: string; severity: string; location: [number, number]; description: string }) => void; location: [number, number]; } const INCIDENT_TYPES = [ { id: 'accident', label: 'Accident', icon: '🚨', color: 'rose' }, { id: 'roadwork', label: 'Road Work', icon: '🚧', color: 'amber' }, { id: 'hazard', label: 'Road Hazard', icon: '⚠️', color: 'orange' }, { id: 'closure', label: 'Road Closure', icon: '🚫', color: 'red' }, { id: 'weather', label: 'Weather Hazard', icon: '🌧️', color: 'blue' }, { id: 'debris', label: 'Debris on Road', icon: '🪨', color: 'yellow' }, ]; const SEVERITY_LEVELS = [ { id: 'low', label: 'Low', desc: 'Minor, no major impact', color: 'emerald' }, { id: 'medium', label: 'Medium', desc: 'Moderate delays expected', color: 'amber' }, { id: 'high', label: 'High', desc: 'Significant impact, avoid', color: 'rose' }, ]; export function IncidentReportModal({ onClose, onSubmit, location }: IncidentReportModalProps) { const [selectedType, setSelectedType] = useState(''); const [selectedSeverity, setSelectedSeverity] = useState(''); const [description, setDescription] = useState(''); const [submitted, setSubmitted] = useState(false); const dialogRef = useRef(null); const handleSubmit = () => { if (!selectedType || !selectedSeverity) return; onSubmit({ type: selectedType, severity: selectedSeverity, location, description }); setSubmitted(true); setTimeout(() => { onClose(); }, 2000); }; if (submitted) { return (

Report Submitted!

Thank you for helping keep roads safer for everyone.

); } return (

Report an Incident

{location[1].toFixed(4)}, {location[0].toFixed(4)}

{INCIDENT_TYPES.map((type) => ( ))}
{SEVERITY_LEVELS.map((level) => ( ))}