"use client" import { Popup } from "react-map-gl/mapbox" import { X } from 'lucide-react' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../../ui/card" import { Button } from "../../ui/button" import { Badge } from "../../ui/badge" interface TimelinePopupProps { longitude: number latitude: number onClose: () => void district: { id: string name: string formattedTime: string timeDescription: string totalIncidents: number earliestTime: string latestTime: string mostFrequentHour: number categoryCounts: Record timeOfDay: string } } export default function TimelinePopup({ longitude, latitude, onClose, district, }: TimelinePopupProps) { // Get top 5 categories const topCategories = Object.entries(district.categoryCounts) .sort(([, countA], [, countB]) => countB - countA) .slice(0, 5) // Get time of day color const getTimeOfDayColor = (timeOfDay: string) => { switch (timeOfDay) { case "morning": return "bg-yellow-400 text-black" case "afternoon": return "bg-orange-500 text-white" case "evening": return "bg-indigo-600 text-white" case "night": return "bg-slate-800 text-white" default: return "bg-green-500 text-white" } } return (
{district.name}
Average incident time analysis
{district.formattedTime}
{district.timeDescription}
Based on {district.totalIncidents} incidents
Earliest incident: {district.earliestTime}
Latest incident: {district.latestTime}
Top incident types:
{topCategories.map(([category, count]) => (
{category} {count}
))}
) }