import { Router } from "express";
import property from "../controllers/property.controller";
import validateData from "../middlewares/validation.middleware";
import authorize from "../middlewares/authorization.middleware";
import {
  basicDetailsSchema,
  duplicateFloorSchema,
  rentDetailsSchema,
  tenantAgreementSchema,
  makeActiveSchema,
  deactivateSchema,
  editNameSchema,
} from "../schemas/property.schema";
import { multerArrayFn, multerSingleFn } from "../middlewares/multer.middleware";

const router = Router();

router.post(
  "/add/basic",
  authorize,
  validateData(basicDetailsSchema),
  property.AddBasicDetails
);

router.post(
  "/add/tenant",
  authorize,
  validateData(tenantAgreementSchema),
  property.AddTenantAgreementDetails
);

router.post(
  "/add/rent",
  authorize,
  validateData(rentDetailsSchema),
  property.AddRentDetails
);

router.get("/list", authorize, property.List);
router.get("/list/web", authorize, property.ListForWeb);
router.get("/details/:propId", authorize, property.Details);
router.get("/details/income/:propId", authorize, property.IncomeDetails);
router.get("/pendingrent/:propId", authorize, property.PendingRent);
router.get("/pendingrent/month/daily/:propId", authorize, property.PendingRentX);
router.get("/info", authorize, property.GetInfo);
router.get("/linkedproperty", authorize, property.LinkedProperty);
/* 
  Gets Client Properties For dropdown
*/
router.get("/list/dropdown", authorize, property.GetList);
router.get("/list/with/vacany", authorize, property.GetListWithVacany);
router.get("/list/web/dropdown", authorize, property.GetListForWeb);

router.post(
  "/floor/duplicate",
  authorize,
  validateData(duplicateFloorSchema),
  property.DuplicateFloor
);

router.post(
  "/status/activate",
  authorize,
  validateData(makeActiveSchema),
  property.MakeActive
);

router.post(
  "/status/deactivate",
  authorize,
  validateData(deactivateSchema),
  property.MakeDeactive
);

router.post("/switch", authorize, property.SwitchProperty);

router.get(
  "/web/renting/rules/:propId",
  authorize,
  property.GetRentingRulesForWeb
);

router.post(
  "/renting/rules/edit",
  authorize,
  property.EditRentingRules
);

router.get(
  "/web/management/details/:propId",
  authorize,
  property.GetManagementDetails
);

router.post(
  "/web/management/details/edit",
  authorize,
  property.EditManagementDetails
);

router.get("/web/dashboard/:propId", authorize, property.WebDashboard);

router.post(
  "/edit/name",
  authorize,
  validateData(editNameSchema),
  property.EditName
);

router.post("/delete", authorize, property.Delete);

router.post(
  "/update/longitude/latitude",
  authorize,
  property.UpdateLongitudeLatitude
);

router.post(
  "/update/tenant/onboarding",
  authorize,
  property.EditTenantOnboardingSetting
);

router.get(
  "/list/tenant/onboarding/:propId",
  authorize,
  property.ListTenantOnboardingSetting
);

router.get(
  "/income/expense/summary/web",
  authorize,
  property.GetIncomeExpenseSummaryForWeb,
);

router.post(
  "/add/landlord/lease",
  authorize,
  property.AddLandlordDetails,
);

router.post(
  "/add/landlord/lease/new",
  authorize,
  property.AddLandlordDetailsX,
);

router.post(
  "/add/lease",
  authorize,
  property.AddLeaseDetails,
);

router.get(
  "/lease/details",
  authorize,
  property.GetLeaseDetails,
);

router.post(
  "/lease/details/update",
  authorize,
  property.EditLandlordDetails,
);

router.post(
  "/update/fine/details",
  authorize,
  property.UpdatePropertyFine,
);

router.post(
  "/toggle/online/payment",
  authorize,
  property.ToggleOnlinePayment,
);

router.post(
  "/toggle/food",
  authorize,
  property.ToggleFood,
);

router.post(
  "/add/location",
  authorize,
  property.AddLocation,
);

router.post(
  "/edit/location",
  authorize,
  property.EditLocation,
);

router.post(
  "/delete/location",
  authorize,
  property.DeleteLocation,
);

router.post(
  "/link/location",
  authorize,
  property.UpdateLocation,
);

router.get(
  "/list/location",
  authorize,
  property.ListLocations,
);

router.post(
  "/add/document",
  authorize,
  multerSingleFn,
  property.UploadDocs
);

router.post(
  "/edit/details",
  authorize,
  property.EditDetails
);

router.post(
  "/add/image",
  authorize,
  (req, res, next) => multerArrayFn(req, res, next, 10),
  property.UploadListingImages
);

router.get(
  "/share",
  property.ShareListing
);

router.post(
  "/toggle/website/visibility",
  authorize,
  property.ToggleWebsiteVisibility,
);

router.post(
  "/update/wifi/password",
  authorize,
  property.UpdateWifiPassword,
);

export default router;
