

const express = require("express");
const router = express.Router();
const gatePassController = require("../../controllers/dispatch/gatePassController");
const upload = require("../../middlewares/upload");
const authenticate = require("../../middlewares/authenticate");
const authorize = require("../../middlewares/authorize");

/**
 * @swagger
 * tags:
 *   name: Gate Pass Management
 */

router.get("/gate-passes", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Gate Pass Management']
    #swagger.summary = 'Get all gate passes'
    #swagger.parameters['status'] = { in: 'query', type: 'string', description: 'Filter by status' }
    #swagger.parameters['date_from'] = { in: 'query', type: 'string', format: 'date' }
    #swagger.parameters['date_to'] = { in: 'query', type: 'string', format: 'date' }
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.responses[200] = { description: "List of gate passes" }
  */
  gatePassController.getAllGatePasses(req, res);
});

router.get("/gate-pass/:id", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Gate Pass Management']
    #swagger.summary = 'Get gate pass by ID'
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.responses[200] = { description: "Gate pass details" }
    #swagger.responses[404] = { description: "Gate pass not found" }
  */
  gatePassController.getGatePassById(req, res);
});

router.delete("/:id", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Gate Pass Management']
    #swagger.summary = 'Delete gate pass'
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.responses[200] = { description: "Gate pass deleted successfully" }
  */
  gatePassController.deleteGatePass(req, res);
});

router.get("/:id/download", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Gate Pass Management']
    #swagger.summary = 'Download gate pass PDF'
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.responses[200] = { description: "PDF file download" }
    #swagger.responses[404] = { description: "Gate pass not found" }
  */
  gatePassController.downloadGatePassPDF(req, res);
});

module.exports = router;