diff --git a/src/components/dashboard/TopWidgets.tsx b/src/components/dashboard/TopWidgets.tsx index 51df5b6..ce0fbd5 100644 --- a/src/components/dashboard/TopWidgets.tsx +++ b/src/components/dashboard/TopWidgets.tsx @@ -7,18 +7,29 @@ import { } from "recharts"; import { fmtBytes, formatAppLabel } from "@/lib/utils"; +import { AppStat, ProtocolStat } from "@/lib/api-types"; + interface TopWidgetsProps { topApps: { - data: { app_label: string; total_bytes: number }[]; + data: AppStat[]; }; topProtocols: { - data: { protocol_label: string; download: number }[]; + data: ProtocolStat[]; }; } const COLORS = ['#3b82f6', '#10b981', '#f59e0b', '#8b5cf6', '#ec4899', '#3b82f6']; export function TopWidgets({ topApps, topProtocols }: TopWidgetsProps) { + const appsData = (topApps.data || []).map(app => ({ + ...app, + total_bytes: (app.download || 0) + (app.upload || 0) + })); + + const protocolsData = (topProtocols.data || []).map(p => ({ + ...p, + total: (p.download || 0) + (p.upload || 0) + })); return (
@@ -26,14 +37,14 @@ export function TopWidgets({ topApps, topProtocols }: TopWidgetsProps) { Top Apps (Total Bandwidth) - {(!topApps.data || topApps.data.length === 0) ? ( + {(!appsData || appsData.length === 0) ? (
No Data
) : (
- + Top Protocols - {(!topProtocols.data || topProtocols.data.length === 0) ? ( + {(!protocolsData || protocolsData.length === 0) ? (
No Data
) : (
- +