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

// router.post("/create",authenticate,upload.array("vehicle_documents"), (req,res)=>{
//      transportController.createTransportAgency(req,res);
// });


// // routes/transportRoutes.js

// router.get("/all",authenticate, (req,res) =>{
//     transportController.getTransportAgencyList(req,res);
// }
// );


// router.get("/dropdown",
//   authenticate,
//   (req,res) =>{
//     transportController.getTransportAgencyDropdown(req,res);
//   }
// );

// // routes/transportRoutes.js

// router.get("/statistics",authenticate, (req,res)=>{
//      transportController.getTransportStatistics(req,res);
// });


// router.delete("/delete/:id",
//   authenticate, (req,res)=>{
//      transportController.deleteTransportAgency(req,res);
// });

// router.post("/add-driver",  authenticate, (req,res)=>{
//   console.log("routes...")
//      transportController.addDriver(req,res);
// });


// router.get("/dropdown-by-mode",
//   authenticate,
//  (req,res)=>{

//      transportController.getTransportAgenciesByMode(req,res);
// });

// router.get("/:id",  authenticate,
//  (req,res)=>{
//      transportController.getTransportAgencyById(req,res);
// });

// router.put("/update/:id",upload.array("vehicle_documents"),
//   authenticate,
//   (req,res)=>{
//      transportController.updateTransportAgency(req,res);
// });

// module.exports = router;

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

/**
 * @swagger
 * tags:
 *   name: Transport Management
 */

router.post("/create", authenticate, upload.array("vehicle_documents"), (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Create transport agency'
    #swagger.requestBody = { required: true, content: { "multipart/form-data": { schema: { type: "object", properties: { agency_name: { type: "string" }, contact_person: { type: "string" }, phone: { type: "string" }, vehicle_documents: { type: "array", items: { type: "string", format: "binary" } } } } } } }
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.createTransportAgency(req, res);
});

router.get("/all", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Get all transport agencies'
    #swagger.parameters['page'] = { in: 'query', type: 'integer' }
    #swagger.parameters['limit'] = { in: 'query', type: 'integer' }
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.getTransportAgencyList(req, res);
});

router.get("/dropdown", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Get transport agency dropdown'
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.getTransportAgencyDropdown(req, res);
});

router.get("/statistics", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Get transport statistics'
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.getTransportStatistics(req, res);
});

router.delete("/delete/:id", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Delete transport agency'
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.deleteTransportAgency(req, res);
});

router.post("/add-driver", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Add driver to transport agency'
    #swagger.requestBody = { required: true, content: { "application/json": { schema: { type: "object", required: ["agency_id", "driver_name", "license_number"], properties: { agency_id: { type: "integer" }, driver_name: { type: "string" }, license_number: { type: "string" }, phone: { type: "string" } } } } } }
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.addDriver(req, res);
});

router.get("/dropdown-by-mode", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Get transport agencies by mode'
    #swagger.parameters['mode'] = { in: 'query', required: true, type: 'string', enum: ['road', 'rail', 'air', 'sea'] }
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.getTransportAgenciesByMode(req, res);
});

router.get("/:id", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Get transport agency by ID'
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.getTransportAgencyById(req, res);
});

router.put("/update/:id", upload.array("vehicle_documents"), authenticate, (req, res) => {
  /*
    #swagger.tags = ['Transport Management']
    #swagger.summary = 'Update transport agency'
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.requestBody = { content: { "multipart/form-data": { schema: { type: "object", properties: { agency_name: { type: "string" }, contact_person: { type: "string" }, vehicle_documents: { type: "array", items: { type: "string", format: "binary" } } } } } } }
    #swagger.security = [{ "bearerAuth": [] }]
  */
  transportController.updateTransportAgency(req, res);
});

module.exports = router;