const express = require('express');
const router = express.Router();
const gateEntryController = require('../controllers/gateEntryController');
const qcApprovalController = require('../controllers/qcApprovalController');
const { authenticate } = require('../middlewares/auth');

// Apply authentication to all routes
router.use(authenticate);

// Gate Entry routes
router.get('/', gateEntryController.getAll);
router.get('/qc-pending', qcApprovalController.getQCPendingEntries);
router.get('/qc-pending/:id', qcApprovalController.getQCPendingEntryById);
router.get('/po-pending', gateEntryController.getPendingPurchaseOrders);
router.get('/po-pending/:poId', gateEntryController.getPOPendingItems);
router.get('/:id', gateEntryController.getById);
router.post('/', gateEntryController.create);
router.put('/:id', gateEntryController.update);
router.post('/:id/check', gateEntryController.checkMaterials);
router.post('/:id/create-grn', gateEntryController.createGRN);
router.post('/:id/qc-approve', qcApprovalController.approveQC);
router.post('/:id/qc-reject', qcApprovalController.rejectQC);
router.delete('/:id', gateEntryController.delete);

module.exports = router;

