const express = require("express");
const router = express.Router();

const authenticate = require("../../middlewares/authenticate");
const authorize = require("../../middlewares/authorize");

const blacklistController = require("../../controllers/securityops/blacklistController");

/**
 * @swagger
 * tags:
 *   name: Blacklist
 *   description: Blacklisted vehicle management APIs
 */


router.post(
  "/blacklist/create",
  authenticate,
  authorize(["security", "qc", "admin"]),
  (req, res) => {
    /*
      #swagger.tags = ['Blacklist']
      #swagger.summary = 'Create a blacklisted vehicle entry'
      #swagger.security = [{ "bearerAuth": [] }]

      #swagger.requestBody = {
        required: true,
        content: {
          "application/json": {
            schema: {
              type: "object",
              properties: {
                vehicleNumber: { type: "string", example: "TS09AB1234" },
                reason: { type: "string", example: "Unauthorized entry attempt" }
              }
            }
          }
        }
      }
    */
    blacklistController.createBlacklistVehicle(req, res);
  }
);


router.get(
  "/blacklist/all",
  authenticate,
  authorize(["security", "qc", "admin"]),
  (req, res) => {
    /*
      #swagger.tags = ['Blacklist']
      #swagger.summary = 'Get all blacklisted vehicles'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    blacklistController.getBlacklistVehicles(req, res);
  }
);


router.post("/vehicles/blacklist", authenticate, authorize(["admin", "security"]), (req, res) =>{

  blacklistController.blacklistVehicle(req, res);
});

router.put("/unblock/:id",
  authenticate,
  authorize(["admin", "security"]),
  (req, res) =>{
    blacklistController.unblockVehicle(req, res);
  }
);

router.get("/check/:plateNumber", (req, res) =>{
  blacklistController.checkVehicleBlacklist(req, res);
  
});


module.exports = router;