From 5123d8c114c2357a99b56389c076f81c3e24c52e Mon Sep 17 00:00:00 2001 From: Nemo Date: Tue, 24 Mar 2026 15:09:06 +0800 Subject: [PATCH] feat: dashboard shows top 5 tickets + invoices with View all links --- app/(app)/dashboard.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/(app)/dashboard.tsx b/app/(app)/dashboard.tsx index 15f8986..7b0bd2c 100644 --- a/app/(app)/dashboard.tsx +++ b/app/(app)/dashboard.tsx @@ -171,7 +171,7 @@ export default function DashboardScreen() { { queryKey: ['dashboard-tickets'], queryFn: async () => { - const res = await api.get('/api/v1/tickets?limit=50'); + const res = await api.get('/api/v1/tickets?limit=20'); const all: any[] = res.data?.data ?? res.data ?? []; return all.filter((t: any) => t.status === 'OPEN' || t.status === 'IN_PROGRESS'); }, @@ -179,7 +179,7 @@ export default function DashboardScreen() { { queryKey: ['dashboard-invoices'], queryFn: async () => { - const res = await api.get('/api/v1/invoices?limit=50'); + const res = await api.get('/api/v1/invoices?limit=20'); const all: any[] = res.data?.data ?? res.data ?? []; const unpaid = all.filter((inv: any) => ['SENT','PARTIAL','OVERDUE'].includes(inv.status) && Number(inv.balance) > 0); unpaid.sort((a: any, b: any) => { @@ -187,7 +187,7 @@ export default function DashboardScreen() { const db = b.dueDate ? new Date(b.dueDate).getTime() : Infinity; return da - db; }); - return unpaid.slice(0, 10); + return unpaid.slice(0, 5); }, }, { @@ -213,7 +213,7 @@ export default function DashboardScreen() { const seen = new Set(); const mergedTickets = [...assignedToMe, ...unassigned].filter((t: any) => { if (seen.has(t.id)) return false; seen.add(t.id); return true; - }).slice(0, 10).sort((a: any, b: any) => (a.priority === 'HIGH' ? -1 : 1) - (b.priority === 'HIGH' ? -1 : 1)); + }).slice(0, 5).sort((a: any, b: any) => (a.priority === 'HIGH' ? -1 : 1) - (b.priority === 'HIGH' ? -1 : 1)); const refetchAll = () => { summaryQ.refetch(); ticketsQ.refetch(); invoicesQ.refetch(); leadsQ.refetch(); }; @@ -274,10 +274,13 @@ export default function DashboardScreen() { No active tickets 🎉 ) : ( - + {mergedTickets.map((t: any) => ( router.push(`/(app)/tasks/${t.id}`)} /> ))} + router.push('/(app)/tasks')} style={{ alignItems: 'center', paddingVertical: 10, marginBottom: 12 }}> + View all tickets → + )} @@ -293,10 +296,13 @@ export default function DashboardScreen() { No unpaid invoices 🎉 ) : ( - + {(unpaidInvoices as any[]).map((inv: any) => ( openPay(inv)} /> ))} + router.push('/(app)/payments')} style={{ alignItems: 'center', paddingVertical: 10, marginBottom: 12 }}> + View all unpaid invoices → + )} {/* ── Leads ── */}