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

router.use(requireAuth);

router.get('/', ctrl.list);
router.get('/my', ctrl.myReports); // partner portal
router.get('/summary', requirePage('purchasing_workreport'), ctrl.summary);
router.get('/export', requirePage('purchasing_workreport'), ctrl.exportExcel);
router.get('/:id', ctrl.getById);
router.post('/', ctrl.create); // partner can create
router.put('/:id', ctrl.update);
router.put('/:id/confirm', requirePage('purchasing_workreport'), ctrl.confirm);
router.put('/:id/reject', requirePage('purchasing_workreport'), ctrl.reject);
router.put('/:id/unconfirm', requirePage('purchasing_workreport'), ctrl.unconfirm);
router.delete('/:id', requirePage('purchasing_workreport'), ctrl.deleteReport);

module.exports = router;
