const express = require('express')
const router = express.Router()
const hospitalController = require('../../controllers/sales/HospitalController.js')
const vendorHistoryController = require('../../controllers/sales/VendorHistoryController.js')
const executivesHistoryController = require('../../controllers/sales/ExecutivesHistoryController.js')
const verifyJWT = require('../../middleware/VerifyJWT.js');
const checkRole = require('../../middleware/CheckRole.js');
const upload = require('../../middleware/UploadImage.js');

router.get('/', verifyJWT, checkRole(['sales']), hospitalController.getAllHospitalByArea);
router.post('/', verifyJWT, upload.single('image'), checkRole(['sales']), hospitalController.storeHospital);
router.patch('/:id', verifyJWT, upload.single('image'), checkRole(['sales']), hospitalController.updateHospital);
router.get('/:id', verifyJWT, checkRole(['sales']), hospitalController.showHospital);

// Vendor History
router.get('/:id/vendor-history', verifyJWT, checkRole(['sales']), vendorHistoryController.getAllVendorHistory);
router.post('/:id/vendor-history', verifyJWT, checkRole(['sales']), vendorHistoryController.storeVendorHistory);
router.get('/:id/vendor-history/:id_vendor_history', verifyJWT, checkRole(['sales']), vendorHistoryController.showVendorHistory);
router.patch('/:id/vendor-history/:id_vendor_history', verifyJWT, checkRole(['sales']), vendorHistoryController.updateVendorHistory);
router.delete('/:id/vendor-history/:id_vendor_history', verifyJWT, checkRole(['sales']), vendorHistoryController.deleteVendorHistory);

// Executives History
router.get('/:id/executives-history', verifyJWT, checkRole(['sales']), executivesHistoryController.getAllExecutivesHistory);
router.post('/:id/executives-history', verifyJWT, checkRole(['sales']), executivesHistoryController.storeExecutivesHistory);
router.get('/:id/executives-history/:id_executives_history', verifyJWT, checkRole(['sales']), executivesHistoryController.showExecutivesHistory);
router.patch('/:id/executives-history/:id_executives_history', verifyJWT, checkRole(['sales']), executivesHistoryController.updateExecutivesHistory);
router.delete('/:id/executives-history/:id_executives_history', verifyJWT, checkRole(['sales']), executivesHistoryController.deleteExecutivesHistory);

module.exports = router;