"use client" import { useState, useMemo } from "react" import { Card } from "@/app/_components/ui/card" import { Button } from "@/app/_components/ui/button" import { ChevronDown, ChevronUp, X } from "lucide-react" import { getCategoryColor } from "@/app/_utils/colors" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/app/_components/ui/tooltip" import { ScrollArea } from "@/app/_components/ui/scroll-area" interface UnitsLegendProps { categories: string[] onClose?: () => void position?: "top-right" | "top-left" | "bottom-right" | "bottom-left" } export default function UnitsLegend({ categories, onClose, position = "bottom-right" }: UnitsLegendProps) { const [collapsed, setCollapsed] = useState(false) const positionClasses = { "top-right": "top-4 right-4", "top-left": "top-4 left-4", "bottom-right": "bottom-4 right-4", "bottom-left": "bottom-4 left-4", } const sortedCategories = useMemo(() => { return [...categories].sort((a, b) => a.localeCompare(b)) }, [categories]) if (categories.length === 0) return null return (

Crime Categories

{onClose && ( )}
{!collapsed && (
{sortedCategories.map((category) => (
{category}

{category}

))}
)} ) }