'use client' import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip } from 'recharts' import type { DeviceStatusBreakdown } from '@/mocks/dashboardData' interface DeviceStatusChartProps { data: DeviceStatusBreakdown } const COLORS = { online: '#22c55e', offline: '#64748b', advertencia: '#eab308', } export default function DeviceStatusChart({ data }: DeviceStatusChartProps) { const total = data.online + data.offline + data.advertencia const segments = [ { name: 'En Línea', value: data.online, color: COLORS.online }, { name: 'Fuera de Línea', value: data.offline, color: COLORS.offline }, { name: 'Advertencia', value: data.advertencia, color: COLORS.advertencia }, ].filter((s) => s.value > 0) if (total === 0) { return (

Estado de Dispositivos

Sin datos
) } return (

Estado de Dispositivos

{segments.map((entry, index) => ( ))} [ `${value} (${total > 0 ? Math.round((value / total) * 100) : 0}%)`, '', ]} />
) }