Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ services:
- event-net
ports:
- "3002:3000"
command: sh -c "npx prisma generate && npm run dev"
command: sh -c "npx prisma generate && npx prisma migrate deploy && npm run prisma:seed && npm run dev"
depends_on:
auth-service-db:
condition: service_healthy
Expand Down Expand Up @@ -103,7 +103,7 @@ services:
- /app/prisma
ports:
- "3003:3000"
command: sh -c "npx prisma generate && npm run dev"
command: sh -c "npx prisma generate && npx prisma migrate deploy && npm run prisma:seed && npm run dev"
networks:
- event-net
depends_on:
Expand Down Expand Up @@ -135,7 +135,7 @@ services:
- /app/prisma
ports:
- "3004:3000"
command: sh -c "npx prisma generate && npm run dev"
command: sh -c "npx prisma generate && npx prisma migrate deploy && npm run dev"
networks:
- event-net
depends_on:
Expand Down Expand Up @@ -165,7 +165,7 @@ services:
- /app/prisma
ports:
- "3005:3000"
command: sh -c "npx prisma generate && npm run dev"
command: sh -c "npx prisma generate && npx prisma migrate deploy && npm run dev"
networks:
- event-net
depends_on:
Expand Down Expand Up @@ -219,7 +219,7 @@ services:
- /app/prisma
ports:
- "3007:3000"
command: sh -c "npx prisma generate && npm run dev"
command: sh -c "npx prisma generate && npx prisma migrate deploy && npm run dev"
networks:
- event-net
depends_on:
Expand Down
36 changes: 31 additions & 5 deletions ems-client/app/dashboard/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { useEffect, useState, useCallback } from "react";
import {useLogger} from "@/lib/logger/LoggerProvider";
import {withAdminAuth} from "@/components/hoc/withAuth";
import { eventAPI } from "@/lib/api/event.api";
import { authAPI } from "@/lib/api/auth.api";
import { bookingAPI } from "@/lib/api/booking.api";
import { EventResponse, EventStatus } from "@/lib/api/types/event.types";

const LOGGER_COMPONENT_NAME = 'AdminDashboard';
Expand Down Expand Up @@ -105,13 +107,15 @@ function AdminDashboard() {
logger.debug(LOGGER_COMPONENT_NAME, 'Fetching dashboard stats');

// Fetch all events to get stats
// Note: API limit is 100, so we fetch with max limit and use total from response
const eventsResponse = await eventAPI.getAllEvents({
limit: 1000, // Large limit to get all events
limit: 100, // Max allowed limit
page: 1
});

if (eventsResponse.success && eventsResponse.data) {
const allEvents = eventsResponse.data.events;
// Use total from API response, which represents total across all pages
const totalEvents = eventsResponse.data.total || allEvents.length;
const activeEvents = allEvents.filter(e => e.status === EventStatus.PUBLISHED).length;

Expand All @@ -122,13 +126,34 @@ function AdminDashboard() {
return startDate > now && e.status === EventStatus.PUBLISHED;
}).length;

// Total registrations: Currently no admin endpoint to get all bookings across all events
// TODO: Implement admin endpoint: GET /api/admin/bookings/stats or similar
// For now, we'll leave it as null and show "N/A"
console.log("Getting Total Registrations");

// Total registrations: Get from booking service admin endpoint
let totalRegistrations: number | null = null;
try {
const registrationsResponse = await bookingAPI.getTotalRegistrations();
if (registrationsResponse.success && registrationsResponse.data) {
totalRegistrations = registrationsResponse.data.totalRegistrations;
}
} catch (error) {
logger.error(LOGGER_COMPONENT_NAME, 'Failed to fetch total registrations', error as Error);
// Leave as null to show "N/A"
}

// Total users: Get from auth service admin endpoint
let totalUsers: number | null = null;
try {
const usersResponse = await authAPI.getTotalUsers();
if (usersResponse.success && usersResponse.data) {
totalUsers = usersResponse.data.totalUsers;
}
} catch (error) {
logger.error(LOGGER_COMPONENT_NAME, 'Failed to fetch total users', error as Error);
// Leave as null to show "N/A"
}

setStats({
totalUsers: null, // TODO: No API endpoint available yet
totalUsers,
totalEvents,
activeEvents,
flaggedUsers: mockFlaggedUsers.length,
Expand All @@ -137,6 +162,7 @@ function AdminDashboard() {
});

logger.info(LOGGER_COMPONENT_NAME, 'Dashboard stats fetched successfully', {
totalUsers,
totalEvents,
activeEvents,
upcomingEvents,
Expand Down
Loading