"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 { Clock, MapPin, Navigation, X, AlertCircle, Calendar, User, Tag, Building2 } from "lucide-react" import { formatDistanceToNow } from "date-fns" import { IconBrandGmail, IconPhone } from "@tabler/icons-react" interface IncidentLogsPopupProps { longitude: number latitude: number onClose: () => void incident: { id: string description?: string category?: string address?: string timestamp: Date district?: string severity?: string source?: string status?: string verified?: boolean | string user_id?: string name?: string email?: string phone?: string avatar?: string role_id?: string role?: string isVeryRecent?: boolean } } export default function IncidentLogsPopup({ longitude, latitude, onClose, incident, }: IncidentLogsPopupProps) { // Format timestamp in a human-readable way const timeAgo = formatDistanceToNow(new Date(incident.timestamp), { addSuffix: true }) // Get severity badge color const getSeverityColor = (severity?: string) => { switch (severity?.toLowerCase()) { case 'high': return 'bg-red-500 text-white' case 'medium': return 'bg-orange-500 text-white' case 'low': return 'bg-yellow-500 text-black' default: return 'bg-gray-500 text-white' } } // Format verification status const verificationStatus = typeof incident.verified === 'boolean' ? incident.verified : incident.verified === 'true' || incident.verified === '1' return (
{/* Custom close button */}

{incident.category || "Incident Report"}

{incident.severity || "Unknown"} Priority
{incident.description && (

Description

{incident.description}

)}

Time

{timeAgo}

Status

{verificationStatus ? "Verified" : "Unverified"}

{incident.address && (

Location

{incident.address}

)} {incident.district && (

District

{incident.district}

)} {incident.source && (

Source

{incident.source}

)} {/* Reporter information section */} {(incident.name || incident.user_id || incident.email || incident.phone) && (

Reporter Details

{incident.name && (

{incident.name} {incident.role && ( {incident.role} )}

)} {incident.email && (

{incident.email}

)} {incident.phone && (

{incident.phone}

)}
)}

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

Incident ID: {incident.id}

{/* Connection line */}
{/* Connection dot */}
{/* Pulsing effect for very recent incidents */} {incident.isVeryRecent && (
)}
) }