"use client"; import { useState } from "react"; import { useAuth } from "@/components/AuthProvider"; import { useIncidents } from "@/lib/useIncidents"; import { c2api } from "@/lib/c2api"; import type { IncidentRecord } from "@/lib/types"; const TYPE_COLORS: Record = { fire: "bg-red-900 text-red-300", police: "bg-blue-900 text-blue-300", ems: "bg-yellow-900 text-yellow-300", accident: "bg-orange-900 text-orange-300", other: "bg-gray-800 text-gray-300", }; function typeBadge(type: string | null) { const cls = TYPE_COLORS[type ?? "other"] ?? TYPE_COLORS.other; return ( {type ?? "other"} ); } function fmtTime(iso: string) { try { return new Date(iso).toLocaleString(); } catch { return iso; } } function IncidentRow({ incident, isAdmin, onResolve }: { incident: IncidentRecord; isAdmin: boolean; onResolve: (id: string) => void; }) { const [expanded, setExpanded] = useState(false); return ( <> setExpanded((v) => !v)} > {typeBadge(incident.type)} {incident.title ?? "—"} {incident.status} {incident.call_ids.length} {fmtTime(incident.started_at)} {fmtTime(incident.updated_at)} {isAdmin && incident.status === "active" && ( )} {expanded && ( {incident.summary && (

{incident.summary}

)} {incident.tags.length > 0 && (
{incident.tags.map((t) => ( {t} ))}
)}
Linked calls: {incident.call_ids.length === 0 ? "none" : incident.call_ids.map((id, i) => ( {id.slice(0, 8)}… {i < incident.call_ids.length - 1 && ", "} ))}
)} ); } function CreateModal({ onClose, onCreate }: { onClose: () => void; onCreate: (body: object) => Promise; }) { const [title, setTitle] = useState(""); const [type, setType] = useState("other"); const [summary, setSummary] = useState(""); const [saving, setSaving] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setSaving(true); try { await onCreate({ title, type, summary: summary || null, status: "active" }); onClose(); } finally { setSaving(false); } } return (

Create Incident

setTitle(e.target.value)} className="w-full bg-gray-800 border border-gray-700 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-indigo-500" />