diff --git a/server-prisma.ts b/server-prisma.ts
index bc32762..8893db3 100644
--- a/server-prisma.ts
+++ b/server-prisma.ts
@@ -803,13 +803,15 @@ app.get('/api/admin/dashboard', authenticateToken, requireAdmin, async (req: Aut
let mrr = 0;
for (const userId of activeUsersIds) {
const studentPayments = allPayments.filter(p => p.userId === userId && (p.status === 'CONFIRMED' || p.status === 'RECEIVED'));
- if (studentPayments.length > 0) {
- const latest = studentPayments[0];
- if (latest.planId && latest.plan) {
- if (latest.plan.cycle === 'MONTHLY') mrr += latest.plan.price;
- else if (latest.plan.cycle === 'YEARLY') mrr += (latest.plan.price / 12);
- } else if (!latest.courseId) {
- mrr += latest.value;
+ // Find the latest payment that is a subscription (either a plan or no courseId)
+ const latestSubscription = studentPayments.find(p => p.planId || (!p.courseId && !p.planId));
+
+ if (latestSubscription) {
+ if (latestSubscription.planId && latestSubscription.plan) {
+ if (latestSubscription.plan.cycle === 'MONTHLY') mrr += latestSubscription.plan.price;
+ else if (latestSubscription.plan.cycle === 'YEARLY') mrr += (latestSubscription.plan.price / 12);
+ } else if (!latestSubscription.courseId) {
+ mrr += latestSubscription.value;
}
}
}
diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx
index 3328e19..372dcf1 100644
--- a/src/components/Navbar.tsx
+++ b/src/components/Navbar.tsx
@@ -220,6 +220,13 @@ export default function Navbar({ user, activeView, setView, onLogout }: NavbarPr
Meus dados
+