const express = require("express");
const router = express.Router();
const qcParamController = require("../../controllers/postgre/qcParamController");
const authenticate = require("../../middlewares/authenticate")

/**
 * @swagger
 * tags:
 *   name: QC Parameters Postgre
 *   description: Quality Control Parameter Management APIs
 */

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

    /*
      #swagger.tags = ['QC Parameters Postgre' ]
      #swagger.summary = 'Create new QC parameter'

      #swagger.requestBody = {
        required: true,
        content: {
          "application/json": {
            schema: {
              type: "object",
              required: ["parameterName"],
              properties: {
                parameterName: {
                  type: "string",
                  example: "Moisture"
                },
                value: {
                  type: "string",
                  example: "%"
                }
              }
            }
          }
        }
      }
    */

    qcParamController.createQCParam(req, res);
  }
);



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

    /*
      #swagger.tags = ['QC Parameters Postgre']
      #swagger.summary = 'Get all QC parameters'
    */

    qcParamController.getQCParams(req, res);
  }
);

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

    
    /*
      #swagger.tags = ['QC Parameters Postgre']
      #swagger.summary = 'Get QC parameters by MaterialType'
    */
     qcParamController.getQCParamsByMaterial(req,res);
    
    });

router.put(
  "/update/:id",
  (req, res) => {

    /*
      #swagger.tags = ['QC Parameters Postgre']
      #swagger.summary = 'Update QC parameter'

      #swagger.parameters['id'] = {
        in: 'path',
        required: true,
        type: 'string',
        example: '665f3f0c8f9b123456789abc'
      }

      #swagger.requestBody = {
        required: true,
        content: {
          "application/json": {
            schema: {
              type: "object",
              properties: {
                parameterName: {
                  type: "string",
                  example: "Moisture"
                },
                value: {
                  type: "string",
                  example: "%"
                }
              }
            }
          }
        }
      }
    */

    qcParamController.updateQCParam(req, res);
  }
);

module.exports = router;