const express = require('express');
const router = express.Router();
const { requireAuth, requirePage } = require('../middleware/auth');
const ctrl = require('../controllers/dailyVisitController');

router.use(requireAuth);

router.get('/today', ctrl.today);
router.get('/export', ctrl.exportCsv);
router.get('/stats', ctrl.stats);
router.get('/', ctrl.list);
router.post('/', requirePage('safety_visit'), ctrl.create);
router.post('/bulk-checkout', requirePage('safety_visit'), ctrl.bulkCheckout);
router.put('/:id', requirePage('safety_visit'), ctrl.update);
router.put('/:id/checkout', requirePage('safety_visit'), ctrl.checkout);
router.delete('/:id', requirePage('safety_visit'), ctrl.deleteVisit);

module.exports = router;
