const express = require('express'); const router = express.Router(); const { protect, staff } = require('../middleware/authMiddleware'); const { scopeList } = require('../utils/campusScope'); const dashboard = require('../utils/dashboard'); // Both follow the person's campus scope inside utils/dashboard.js. // @desc Today's events and how they're going, money in, and what's waiting (1.49.0) // @route GET /api/dashboard/today // @access Private/Staff (money and waiting items for supervisors and admins) router.get('/today', protect, staff, scopeList, async (req, res) => { try { res.json(await dashboard.today(req)); } catch (e) { res.status(400).json({ message: e.message }); } }); // @desc Command palette search (?q=): events; supervisors also payments by amount; admins people and registrations // @route GET /api/dashboard/search // @access Private/Staff router.get('/search', protect, staff, scopeList, async (req, res) => { try { res.json({ results: await dashboard.search(req, req.query.q) }); } catch (e) { res.status(400).json({ message: e.message }); } }); module.exports = router;