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

const employeeOnboardingController = require("../../controllers/postgre/employeeOnboardingController");
const authenticate = require("../../middlewares/authenticate");
const upload = require("../../middlewares/upload");
const onboardingUpload = upload.fields([
  { name: "offer_letter_file", maxCount: 1 },
  { name: "identity_proof_file", maxCount: 1 },
  { name: "address_proof_file", maxCount: 1 },
  {
    name: "education_certificates_file",
    maxCount: 1,
  },
  { name: "policy_acceptance_file", maxCount: 1 },
  { name: "training_assignment_file", maxCount: 1 },
]);
/**
 * @swagger
 * tags:
 *   name: Employee Onboarding
 *   description: Employee onboarding creation, listing, update and deletion APIs
 */

/* ===========================
   ✅ CREATE EMPLOYEE ONBOARDING
=========================== */


router.post(
  "/create",
  authenticate,
  onboardingUpload,
  (req, res) => {
    /*
      #swagger.tags = ['Employee Onboarding']
      #swagger.summary = 'Create employee onboarding'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    employeeOnboardingController.createEmployeeOnboarding(req, res);
  }
);

/* ===========================
   ✅ UPDATE EMPLOYEE ONBOARDING
=========================== */
router.put(
  "/:id",

  authenticate,
  onboardingUpload,
  (req, res) => {
    /*
      #swagger.tags = ['Employee Onboarding']
      #swagger.summary = 'Patch update employee onboarding by ID'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    employeeOnboardingController.updateEmployeeOnboarding(req, res);
  }
);



/* ===========================
   ✅ GET ALL EMPLOYEE ONBOARDINGS
=========================== */
router.get(
  "/all",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Employee Onboarding']
      #swagger.summary = 'Get all employee onboardings'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    employeeOnboardingController.getEmployeeOnboardings(req, res);
  }
);

/* ===========================
   ✅ GET EMPLOYEE ONBOARDING BY ID
=========================== */
router.get(
  "/:id",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Employee Onboarding']
      #swagger.summary = 'Get employee onboarding by ID'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    employeeOnboardingController.getEmployeeOnboardingById(req, res);
  }
);


router.get(
  "/employees/onboarding-list",
  authenticate,
  (req, res) => {
     /*
      #swagger.tags = ['Employee Onboarding']
      #swagger.summary = 'Get employee onboarding list'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    employeeOnboardingController.getEmployeesForOnboarding(req, res);
    }
);
/* ===========================
   ✅ DELETE EMPLOYEE ONBOARDING
=========================== */
router.delete(
  "/:id",
  authenticate,
  (req, res) => {
    /*
      #swagger.tags = ['Employee Onboarding']
      #swagger.summary = 'Delete employee onboarding (soft delete)'
      #swagger.security = [{ "bearerAuth": [] }]
    */

    employeeOnboardingController.deleteEmployeeOnboarding(req, res);
  }
);

module.exports = router;