'use client'; import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip, Legend } from 'recharts'; import { AssigneeDistribution } from '@/lib/types'; interface TeamDistributionChartProps { distribution: AssigneeDistribution[]; className?: string; } const COLORS = [ 'hsl(142, 76%, 36%)', // Green 'hsl(217, 91%, 60%)', // Blue 'hsl(45, 93%, 47%)', // Yellow 'hsl(0, 84%, 60%)', // Red 'hsl(262, 83%, 58%)', // Purple 'hsl(319, 70%, 52%)', // Pink 'hsl(173, 80%, 40%)', // Teal 'hsl(27, 96%, 61%)', // Orange ]; export function TeamDistributionChart({ distribution, className }: TeamDistributionChartProps) { // Préparer les données pour le graphique (top 8 membres) const chartData = distribution.slice(0, 8).map((assignee, index) => ({ name: assignee.displayName, value: assignee.totalIssues, completed: assignee.completedIssues, inProgress: assignee.inProgressIssues, percentage: assignee.percentage, color: COLORS[index % COLORS.length] })); const CustomTooltip = ({ active, payload }: { active?: boolean; payload?: Array<{ payload: { name: string; value: number; completed: number; inProgress: number; percentage: number } }> }) => { if (active && payload && payload.length) { const data = payload[0].payload; return (

{data.name}

Total: {data.value} tickets
Complétés: {data.completed}
En cours: {data.inProgress}
Part équipe: {data.percentage}%
); } return null; }; // eslint-disable-next-line @typescript-eslint/no-explicit-any const CustomLabel = (props: any) => { const { cx, cy, midAngle, innerRadius, outerRadius, percentage } = props; if (percentage < 5) return null; // Ne pas afficher les labels pour les petites sections const RADIAN = Math.PI / 180; const radius = innerRadius + (outerRadius - innerRadius) * 0.5; const x = cx + radius * Math.cos(-midAngle * RADIAN); const y = cy + radius * Math.sin(-midAngle * RADIAN); return ( cx ? 'start' : 'end'} dominantBaseline="central" fontSize="12" fontWeight="500" > {`${percentage}%`} ); }; return (
{chartData.map((entry, index) => ( ))} } /> ( {value} ({entry.payload.value}) )} />
); }