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

router.use(requireAuth);

router.get('/', ctrl.list);
router.get('/my', ctrl.mySchedules); // partner portal
router.get('/:id', ctrl.getById);
router.post('/', requirePage('purchasing_schedule'), ctrl.create);
router.post('/request', ctrl.requestSchedule); // 협력업체 작업 신청
router.put('/:id', requirePage('purchasing_schedule'), ctrl.update);
router.put('/:id/status', requirePage('purchasing_schedule'), ctrl.updateStatus);
router.put('/:id/approve', requirePage('purchasing_schedule'), ctrl.approveRequest);
router.put('/:id/reject', requirePage('purchasing_schedule'), ctrl.rejectRequest);
router.delete('/:id', requirePage('purchasing_schedule'), ctrl.deleteSchedule);

module.exports = router;
