const express = require('express');
const router = express.Router();
const ctrl = require('../controllers/purchaseRequestController');
const { createRequirePage } = require('../../../shared/middleware/pagePermission');
const { getDb } = require('../dbPool');
const requirePage = createRequirePage(getDb);

// 보조 데이터
router.get('/consumable-items', ctrl.getConsumableItems);
router.get('/vendors', ctrl.getVendors);

// 구매신청 CRUD
router.get('/', ctrl.getAll);
router.get('/:id', ctrl.getById);
router.post('/', ctrl.create);
router.put('/:id/hold', requirePage('factory_purchases'), ctrl.hold);
router.put('/:id/revert', requirePage('factory_purchases'), ctrl.revert);
router.delete('/:id', ctrl.delete);

module.exports = router;
