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

const salesEnquiryController = require("../../controllers/sales/salesEnquiryController");
const authenticate = require("../../middlewares/authenticate");

/**
 * @swagger
 * tags:
 *   name: Sales Enquiry
 *   description: Sales enquiry creation, listing, update and deletion APIs
 */

/* ===========================
   ✅ CREATE SALES ENQUIRY
=========================== */
router.post(
  "/create",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Sales Enquiry']
      #swagger.summary = 'Create sales enquiry'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    salesEnquiryController.createSalesEnquiry(req, res);
  }
);

/* ===========================
   ✅ UPDATE SALES ENQUIRY
=========================== */
router.patch(
  "/:id",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Sales Enquiry']
      #swagger.summary = 'Patch update sales enquiry by ID'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    salesEnquiryController.updateSalesEnquiry(req, res);
  }
);

/* ===========================
   ✅ GET ALL SALES ENQUIRIES
=========================== */
router.get(
  "/all",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Sales Enquiry']
      #swagger.summary = 'Get all sales enquiries'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    salesEnquiryController.getSalesEnquiries(req, res);
  }
);

/* ===========================
   ✅ GET SALES ENQUIRY BY ID
=========================== */
router.get(
  "/:id",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Sales Enquiry']
      #swagger.summary = 'Get sales enquiry by ID'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    salesEnquiryController.getSalesEnquiryById(req, res);
  }
);

/* ===========================
   ✅ DELETE SALES ENQUIRY
=========================== */
router.delete(
  "/:id",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Sales Enquiry']
      #swagger.summary = 'Delete sales enquiry (soft delete)'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    salesEnquiryController.deleteSalesEnquiry(req, res);
  }
);

module.exports = router;