"use client"; import type { CaseReport } from "@/lib/types"; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend, PieChart, Pie, Cell, } from "recharts"; import { FolderOpen, TrendingUp, TrendingDown } from "lucide-react"; const COLORS = [ "#171717", "#525252", "#a3a3a3", "#d4d4d4", "#737373", "#404040", "#e5e5e5", "#262626", ]; function formatMonth(period: string): string { const [year, month] = period.split("-"); const months = [ "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez", ]; return `${months[parseInt(month, 10) - 1]} ${year.slice(2)}`; } export function CasesTab({ data }: { data: CaseReport }) { const chartData = data.monthly.map((m) => ({ ...m, name: formatMonth(m.period), })); return (
{/* Summary cards */}
Eröffnet

{data.total.opened}

Geschlossen

{data.total.closed}

Aktiv

{data.total.active}

{/* Bar chart: opened/closed per month */}

Akten pro Monat

{chartData.length === 0 ? (

Keine Daten im gewählten Zeitraum

) : ( )}
{/* Pie charts row */}
{/* By type */}

Nach Verfahrensart

{data.by_type.length === 0 ? (

Keine Daten

) : (
{data.by_type.map((_, i) => ( ))}
{data.by_type.map((item, i) => (
{item.case_type} {item.count}
))}
)}
{/* By court */}

Nach Gericht

{data.by_court.length === 0 ? (

Keine Daten

) : (
{data.by_court.map((item, i) => { const maxCount = Math.max(...data.by_court.map((c) => c.count)); const pct = maxCount > 0 ? (item.count / maxCount) * 100 : 0; return (
{item.court} {item.count}
); })}
)}
); }