import React from 'react' import { Activity, Calendar, CheckCircle, AlertTriangle, LineChart, PieChart, FileText } from 'lucide-react' import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/app/_components/ui/card" import { Separator } from "@/app/_components/ui/separator" import { cn } from "@/app/_lib/utils" import { getMonthName } from "@/app/_utils/common" import { SidebarSection } from "../components/sidebar-section" import { StatCard } from "../components/stat-card" import { CrimeTypeCard, ICrimeTypeCardProps } from "../components/crime-type-card" import { ICrimeAnalytics } from '@/app/(pages)/(admin)/dashboard/crime-management/crime-overview/_hooks/use-crime-analytics' import { MONTHS } from '@/app/_utils/const/common' interface ISidebarStatisticsTabProps { crimeStats: ICrimeAnalytics selectedMonth?: number | "all" selectedYear: number } export function SidebarStatisticsTab({ crimeStats, selectedMonth = "all", selectedYear }: ISidebarStatisticsTabProps) { const topCategories = crimeStats.categoryCounts ? Object.entries(crimeStats.categoryCounts) .sort((a, b) => b[1] - a[1]) .slice(0, 4) .map(([type, count]) => { const percentage = Math.round(((count) / crimeStats.totalIncidents) * 100) || 0 return { type, count, percentage } }) : [] return ( <> Monthly Incidents {selectedYear}
{crimeStats.incidentsByMonth.map((count: number, i: number) => { const maxCount = Math.max(...crimeStats.incidentsByMonth) const height = maxCount > 0 ? (count / maxCount) * 100 : 0 return (
) })}
{MONTHS.map((month, i) => ( {month.substring(0, 3)} ))}
}>
} bgColor="bg-gradient-to-r from-blue-900/30 to-blue-800/20" /> c > 0).length || 1) ).toString()} change={selectedMonth !== 'all' ? `in ${getMonthName(Number(selectedMonth))}` : "per active month"} isPositive={false} icon={} bgColor="bg-gradient-to-r from-amber-900/30 to-amber-800/20" /> 50} icon={} bgColor="bg-gradient-to-r from-green-900/30 to-green-800/20" />
}>
{topCategories.length > 0 ? ( topCategories.map((category: ICrimeTypeCardProps) => ( )) ) : (

No crime data available

Try selecting a different time period

)}
) }