const express = require('express');
const router = express.Router();
const dispatchController = require('../controllers/dispatchController');

// Get all dispatches
router.get('/', dispatchController.getAll);

// Get dispatch by request ID
router.get('/request/:requestId', dispatchController.getByRequestId);

// Create dispatch
router.post('/', (req, res) => {
    const sendNotification = req.sendNotification;
    const broadcastDispatch = req.broadcastDispatch;
    dispatchController.create(req, res, sendNotification, broadcastDispatch);
});

// Cancel dispatch
router.post('/cancel', dispatchController.cancel);

module.exports = router;

