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



const uploadFields = [
  { name: "profileImage", maxCount: 1 },
  { name: "panFile", maxCount: 1 },
  { name: "aadharFile", maxCount: 1 },
  { name: "passportFile", maxCount: 1 },
  { name: "licenseFile", maxCount: 1 },
  { name: "offerLetterFile", maxCount: 1 },
{ name: "identityProofFile", maxCount: 1 },
{ name: "addressProofFile", maxCount: 1 },
{ name: "educationCertificatesFile", maxCount: 1 },
{ name: "policyAcceptanceFile", maxCount: 1 },
{ name: "trainingAssignmentFile", maxCount: 1 },
];

router.post("/create",authenticate, upload.fields(uploadFields), controller.createEmployee);

/* READ */
router.get("/all",authenticate, controller.getEmployees);

router.get("/:id",authenticate, controller.getEmployeeById);

/* UPDATE */
router.put(
  "/:id",
  authenticate,
  upload.fields([
    { name: "profileImage", maxCount: 1 },
    { name: "panFile", maxCount: 1 },
    { name: "aadharFile", maxCount: 1 },
    { name: "passportFile", maxCount: 1 },
    { name: "licenseFile", maxCount: 1 },
    { name: "offerLetterFile", maxCount: 1 },
{ name: "identityProofFile", maxCount: 1 },
{ name: "addressProofFile", maxCount: 1 },
{ name: "educationCertificatesFile", maxCount: 1 },
{ name: "policyAcceptanceFile", maxCount: 1 },
{ name: "trainingAssignmentFile", maxCount: 1 },
  ]),
  controller.updateEmployee
);

/* DELETE */
router.delete("/:id",authenticate, controller.deleteEmployee);

module.exports = router;


