'use client'; import { useQuery } from '@tanstack/react-query'; import { api } from '@/lib/api'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Skeleton } from '@/components/ui/skeleton'; import { Users, Wifi, DollarSign, AlertTriangle, Ticket, ClipboardList } from 'lucide-react'; interface DashboardSummary { subscribers: { total: number; active: number; pending: number; suspended: number }; billing: { unpaidInvoices: number; overdueInvoices: number }; support: { openTickets: number; inProgressTickets: number }; tasks: { pending: number }; revenue: { thisMonth: number; lastMonth: number; trend: number }; leads: { total: number; new: number }; } function KpiCard({ label, value, sub, icon: Icon, color, isLoading, }: { label: string; value: string; sub?: string; icon: React.ElementType; color: string; isLoading: boolean; }) { return ( {label}
{isLoading ? ( ) : ( <>

{value}

{sub &&

{sub}

} )}
); } export default function DashboardPage() { const { data, isLoading, error } = useQuery({ queryKey: ['dashboard', 'summary'], queryFn: async () => { const res = await api.get('/api/v1/dashboard/summary'); return res.data; }, }); const fmt = (n: number) => n?.toLocaleString() ?? '—'; const peso = (n: number) => '₱' + (n ?? 0).toLocaleString('en-PH', { minimumFractionDigits: 2 }); return (

Dashboard

Overview of your ISP operations

{error && (
Failed to load dashboard data.
)} {/* KPI Row 1 */}
{/* KPI Row 2 */}
{/* Quick stats */} Subscriber Breakdown {isLoading ? (
) : (
{[ { label: 'Active', value: data?.subscribers?.active ?? 0, color: '#059669' }, { label: 'Pending', value: data?.subscribers?.pending ?? 0, color: '#D97706' }, { label: 'Suspended', value: data?.subscribers?.suspended ?? 0, color: '#DC2626' }, { label: 'Total', value: data?.subscribers?.total ?? 0, color: '#0891B2' }, ].map((item) => (

{item.value}

{item.label}

))}
)}
); }