diff --git a/server.ts b/server.ts index 9e8fa67..5620f7c 100644 --- a/server.ts +++ b/server.ts @@ -793,6 +793,11 @@ app.get('/api/admin/dashboard', authenticateToken, requireAdmin, (req: Authentic } } + // Total Revenue Calculation + const totalRevenue = db.payments + .filter(p => p.status === 'CONFIRMED' || p.status === 'RECEIVED') + .reduce((sum, p) => sum + p.value, 0); + // Generate Revenue Data for Charts (Last 30 Days) const thirtyDaysAgo = new Date(); thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30); @@ -858,6 +863,7 @@ app.get('/api/admin/dashboard', authenticateToken, requireAdmin, (req: Authentic res.json({ stats: { mrr, + totalRevenue, activeSubscribers: totalActive, trialSubscribers: totalTrial, overdueSubscribers: totalOverdue, diff --git a/src/components/AdminDashboard.tsx b/src/components/AdminDashboard.tsx index 6b4fe74..9cba89e 100644 --- a/src/components/AdminDashboard.tsx +++ b/src/components/AdminDashboard.tsx @@ -48,6 +48,7 @@ interface PaymentLog { interface DashboardStats { mrr: number; + totalRevenue: number; activeSubscribers: number; trialSubscribers: number; overdueSubscribers: number; @@ -340,8 +341,22 @@ export default function AdminDashboard({ token }: AdminDashboardProps) { - {/* METRICS ROW (MRR, Actives, Overdue, Cancelled) */} -
Faturamento Total
++ R$ {stats.totalRevenue ? stats.totalRevenue.toLocaleString('pt-BR', { minimumFractionDigits: 2 }) : '0,00'} +
+Soma de todos os pagamentos
+