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

const shiftAssignmentsController = require("../../controllers/hrandpayrollsController/shiftAssignedController");
const authenticate = require("../../middlewares/authenticate");

router.post("/assign", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Assign a shift to an employee'
  #swagger.security = [{ "bearerAuth": [] }]
  #swagger.requestBody = {
    required: true,
    content: {
      "application/json": {
        schema: {
          type: "object",
          properties: {
            employee_id: { type: "string" },
            shift_id: { type: "string" },
            date: { type: "string", format: "date" }
          },
          required: ["employee_id", "shift_id", "date"]
        }
      }
    }
  }
  */
  shiftAssignmentsController.assignShiftToEmployee(req, res);
});

router.post("/bulk-assign", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Bulk assign shifts to employees'
  #swagger.security = [{ "bearerAuth": [] }]
  #swagger.requestBody = {
    required: true,
    content: {
      "application/json": {
        schema: {
          type: "array",
          items: {
            type: "object",
            properties: {
              employee_id: { type: "string" },
              shift_id: { type: "string" },
              date: { type: "string", format: "date" }
            },
            required: ["employee_id", "shift_id", "date"]
          }
        }
      }
    }
  }
  */
  shiftAssignmentsController.bulkAssignShift(req, res);
});

router.get("/employee/current/:employee_id", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Get current shift assignment for an employee'
  #swagger.security = [{ "bearerAuth": [] }]
  */
  shiftAssignmentsController.getEmployeeCurrentShift(req, res);
});


router.get("/all", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Get all shift assignments with filters'
  #swagger.security = [{ "bearerAuth": [] }]
  #swagger.parameters['employee_id'] = { in: 'query', type: 'string' }
  #swagger.parameters['shift_id'] = { in: 'query', type: 'string' }
  #swagger.parameters['date'] = { in: 'query', type: 'string', format: 'date' }
  */
  shiftAssignmentsController.getShiftAssignments(req, res);
});

router.put("/deactivate", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Deactivate a shift assignment'
  #swagger.security = [{ "bearerAuth": [] }]
  */
  shiftAssignmentsController.deactivateShiftAssignment(req, res);
});


router.get("/employee/:employee_id/history", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Get shift assignment history for an employee'
  #swagger.security = [{ "bearerAuth": [] }]
  */
  shiftAssignmentsController.getEmployeeShiftHistory(req, res);
});

router.get("/shift/:shift_id", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Get shift assignments for a specific shift'
  #swagger.security = [{ "bearerAuth": [] }]
  */
  shiftAssignmentsController.getAssignmentsByShift(req, res);
});

router.get("/:id", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Get shift assignment by ID'
  #swagger.security = [{ "bearerAuth": [] }]
  */
  shiftAssignmentsController.getShiftAssignmentById(req, res);
});

router.put("/:id", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Update shift assignment by ID'
  #swagger.security = [{ "bearerAuth": [] }]
  */
  shiftAssignmentsController.updateShiftAssignment(req, res);
});

router.delete("/:id", authenticate, (req, res) => {
  /*
  #swagger.tags = ['Shift Assignments']
  #swagger.summary = 'Delete shift assignment by ID'
  #swagger.security = [{ "bearerAuth": [] }]
  */
  shiftAssignmentsController.deleteShiftAssignment(req, res);
});

module.exports = router;