const express = require("express");
const router = express.Router();
const salesQController = require("../../controllers/sales/salesQuotationsController");
const authenticate = require("../../middlewares/authenticate");
const upload = require("../../middlewares/upload")

/**
 * @swagger
 * tags:
 *   name: Sales Quotation
 *   description: Sales Quotation APIs
 */

router.post(
  "/create",
  authenticate,
  (req, res) => {

    /*
      #swagger.tags = ['Sales Quotation']
      #swagger.summary = 'Create new sales quotation'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    salesQController.createQuotation(req, res);
  }
);

router.get(
  "/all",
  authenticate,
  (req, res) => {

    /*
      #swagger.tags = ['Sales Quotation']
      #swagger.summary = 'Get all sales quotations'
      #swagger.security = [{ "bearerAuth": [] }]
      #swagger.parameters['page'] = {
        in: 'query',
        description: 'Page number',
        required: false,
        type: 'integer',
        example: 1
      }
      #swagger.parameters['limit'] = {
        in: 'query',
        description: 'Number of records per page',
        required: false,
        type: 'integer',
        example: 10
      }
    */

    salesQController.getQuotations(req, res);
  }
);
router.get("/organization",authenticate, (req, res)=>{
  salesQController.getOrganization(req, res);
} );

router.get("/:id",authenticate, (req, res) => {
    /*
      #swagger.tags = ['Sales Quotation']
      #swagger.summary = 'Get sales quotation by id'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    salesQController.getQuotationById(req, res);
  }
);

router.put("/upload/:id",authenticate, upload.single("file"), (req,res) =>{
 salesQController.uploadQuotation(req,res);
}
);


router.put("/approve/:id",authenticate, (req, res)=>{
  salesQController.approveQuotation(req,res)
} )




module.exports = router;