import { Router } from "express";
import complaint from "../controllers/complaint.controller";
import validateData from "../middlewares/validation.middleware";
import {
  addComplaintFeedbackSchema,
  addComplaintSchema,
  assignComplaintSchema,
  updateStatusSchema,
} from "../schemas/complaint.schema";
import authorize from "../middlewares/authorization.middleware";
import { multerSingleFn } from "../middlewares/multer.middleware";

const router = Router();

router.post(
  "/add",
  authorize,
  multerSingleFn,
  validateData(addComplaintSchema),
  complaint.Add
);
router.post(
  "/admin/add",
  authorize,
  multerSingleFn,
  validateData(addComplaintSchema),
  complaint.AddByAdmin
);
router.get("/tenant/list", authorize, complaint.ListForTenant);
router.get("/client/list", authorize, complaint.ListForClient);
router.get("/client/list/new", authorize, complaint.ListForClientX);
router.get("/web/list", authorize, complaint.ListForWeb);
router.get("/prop/web/list", authorize, complaint.ListForWebForProp);
//Get Client Complaints by property
router.get("/client/list/prop", authorize, complaint.ListForClientForProp);
router.get(
  "/tenant/:complaintId",
  authorize,
  complaint.GetComplaintDetailsByTenant
);
router.get(
  "/:complaintId/:complaintFor",
  authorize,
  complaint.GetComplaintDetails
);

router.post(
  "/assign",
  authorize,
  validateData(assignComplaintSchema),
  complaint.AssignComplaint
);
router.post(
  "/status/update",
  authorize,
  validateData(updateStatusSchema),
  complaint.UpdateStatus
);
router.post(
  "/add/feedback",
  authorize,
  validateData(addComplaintFeedbackSchema),
  complaint.AddFeedback
);
router.post(
  "/delete",
  authorize,
  complaint.Delete
);

router.post(
  "/edit/staffNote",
  authorize,
  complaint.EditStaffNote
);

router.get(
  "/analytics",
  authorize,
  complaint.ComplaintAnalytics
);

router.post(
  "/reopen",
  authorize,
  multerSingleFn,
  complaint.Reopen,
);

router.post(
  "/translate/description",
  authorize,
  complaint.Translate,
);

export default router;
