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

router.use(requireAuth);

router.get('/', ctrl.list);
router.get('/stats', ctrl.stats);
router.get('/:id', ctrl.getById);
router.post('/', ctrl.create); // any authenticated user can request
router.put('/:id/approve', requirePage('purchasing_daylabor'), ctrl.approve);
router.put('/:id/reject', requirePage('purchasing_daylabor'), ctrl.reject);
router.put('/:id/complete', requirePage('purchasing_daylabor'), ctrl.complete);

module.exports = router;
