UserCampusScope relation and audit action; scopeEvent/scopeList/unscopedOnly/ campusIndependent/scopeBroadcast markers; tests/campusScopeRoutes.test.js (still failing: events, payments, registrations, scan locks, tickets left). Can't delete a campus that has scoped staff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 lines
1.1 KiB
JavaScript
18 lines
1.1 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const { getStaffDashboardStats, getSupervisorDashboardStats, getAdminDashboardStats, getOverviewStats } = require('../controllers/statsController');
|
|
const { protect, staff, supervisor, admin } = require('../middleware/authMiddleware');
|
|
const { scopeList } = require('../utils/campusScope');
|
|
|
|
// One endpoint per dashboard — each returns exactly what that dashboard renders in a
|
|
// single response instead of the dashboard making several separate calls (and, previously,
|
|
// pulling full payments/events lists just to reduce them to a couple of numbers).
|
|
router.get('/staff', protect, staff, scopeList, getStaffDashboardStats);
|
|
router.get('/supervisor', protect, supervisor, scopeList, getSupervisorDashboardStats);
|
|
router.get('/admin', protect, admin, getAdminDashboardStats);
|
|
|
|
// Month-over-month KPIs + trend + top events, shared by the Admin and Supervisor dashboards.
|
|
// Staff never sees financial data, so this has no staff-accessible route.
|
|
router.get('/overview', protect, supervisor, scopeList, getOverviewStats);
|
|
|
|
module.exports = router; |