'use client' import { useRouter, usePathname, useSearchParams } from 'next/navigation' import { useTransition } from 'react' import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, } from 'recharts' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select' import type { JobsPerDayResult } from '@/lib/insights/agent-throughput' import { JOB_STATUS_COLORS } from '@/lib/chart-colors' interface Props { data: JobsPerDayResult productList: { id: string; name: string }[] currentProductId?: string } function formatDuration(seconds: number | null): string { if (seconds === null) return '—' const m = Math.floor(seconds / 60) const s = seconds % 60 return m > 0 ? `${m}m ${s}s` : `${s}s` } const STACKED_STATUSES = ['queued', 'claimed', 'running', 'done', 'failed', 'cancelled', 'skipped'] as const export function AgentThroughputCard({ data, productList, currentProductId }: Props) { const router = useRouter() const pathname = usePathname() const searchParams = useSearchParams() const [isPending, startTransition] = useTransition() const { perDay, kpi } = data const isEmpty = perDay.every( d => d.done + d.failed + d.queued + d.claimed + d.running + d.cancelled + d.skipped === 0, ) function handleProductChange(value: string | null) { if (value === null) return startTransition(() => { const params = new URLSearchParams(searchParams.toString()) if (value === '__all__') { params.delete('product') } else { params.set('product', value) } router.replace(`${pathname}?${params.toString()}`) }) } return (
{/* KPI strip + product filter */}
{kpi.todayCount}
Jobs vandaag
{kpi.successRate7d === 0 ? '—' : `${Math.round(kpi.successRate7d * 100)}%`}
Success-rate (7d)
{formatDuration(kpi.avgDurationSeconds7d)}
Avg duration (7d)
{productList.length > 0 && ( )}
{/* Chart */} {isEmpty ? (

Geen agent-activiteit in de laatste 2 weken

) : ( (v as string).slice(5)} /> {STACKED_STATUSES.map(status => ( ))} )}
) }