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('purchasing_visit'), ctrl.create);
router.post('/bulk-checkout', requirePage('purchasing_visit'), ctrl.bulkCheckout);
router.put('/:id', requirePage('purchasing_visit'), ctrl.update);
router.put('/:id/checkout', requirePage('purchasing_visit'), ctrl.checkout);
router.delete('/:id', requirePage('purchasing_visit'), ctrl.deleteVisit);

module.exports = router;
