import React, { useState, useEffect } from 'react'; const IncidentQueue = ({ showToast }) => { const [incidents, setIncidents] = useState([]); const [currentTime, setCurrentTime] = useState(new Date()); const fetchIncidents = async () => { try { const res = await fetch(`/api/incidents`); const data = await res.json(); setIncidents(data); } catch (err) { console.error(err); } }; useEffect(() => { fetchIncidents(); const timer = setInterval(() => setCurrentTime(new Date()), 1000); return () => clearInterval(timer); }, []); const handleResolve = async (id) => { try { const res = await fetch(`/api/incidents/resolve`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ incident_id: id }) }); if (res.ok) { if (showToast) showToast(`Incident #${id} has been marked as Resolved.`, 'success'); fetchIncidents(); } } catch (err) { console.error(err); } }; const handleEscalate = async (id) => { try { const res = await fetch(`/api/incidents/escalate`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ incident_id: id }) }); if (res.ok) { if (showToast) showToast(`🚨 Emergency Response Team (ERT) dispatched for Incident #${id}!`, 'danger'); fetchIncidents(); } } catch (err) { console.error(err); } }; return (