"use client" import { Popup } from "react-map-gl/mapbox" import { Badge } from "@/app/_components/ui/badge" import { Card } from "@/app/_components/ui/card" import { Separator } from "@/app/_components/ui/separator" import { Button } from "@/app/_components/ui/button" import { MapPin, AlertTriangle, Calendar, Clock, Tag, Bookmark, FileText, Navigation, X } from "lucide-react" interface IncidentPopupProps { longitude: number latitude: number onClose: () => void incident: { id: string district?: string category?: string type_category?: string | null description?: string status?: string address?: string | null timestamp?: Date latitude?: number longitude?: number } } export default function CrimePopup({ longitude, latitude, onClose, incident }: IncidentPopupProps) { const formatDate = (date?: Date) => { if (!date) return "Unknown date" return new Date(date).toLocaleDateString() } const formatTime = (date?: Date) => { if (!date) return "Unknown time" return new Date(date).toLocaleTimeString() } const getStatusBadge = (status?: string) => { if (!status) return Unknown const statusLower = status.toLowerCase() if (statusLower.includes("resolv") || statusLower.includes("closed")) { return Resolved } if (statusLower.includes("progress") || statusLower.includes("invest")) { return In Progress } if (statusLower.includes("open") || statusLower.includes("new")) { return Open } return {status} } // Determine border color based on status const getBorderColor = (status?: string) => { if (!status) return "border-l-gray-400" const statusLower = status.toLowerCase() if (statusLower.includes("resolv") || statusLower.includes("closed")) { return "border-l-emerald-600" } if (statusLower.includes("progress") || statusLower.includes("invest")) { return "border-l-amber-500" } if (statusLower.includes("open") || statusLower.includes("new")) { return "border-l-blue-600" } return "border-l-gray-400" } return (
{/* Custom close button */}

{incident.category || "Unknown Incident"}

{getStatusBadge(incident.status)}
{incident.description && (

{incident.description}

)} {/* Improved section headers */}
{incident.district && (

District

{incident.district}

)} {incident.address && (

Location

{incident.address}

)} {incident.timestamp && ( <>

Date

{formatDate(incident.timestamp)}

Time

{formatTime(incident.timestamp)}

)} {incident.type_category && (

Type

{incident.type_category}

)}

Coordinates: {latitude.toFixed(6)}, {longitude.toFixed(6)}

ID: {incident.id}

) }