const express = require("express");
const { PropertyController } = require("../../controllers/api");
const { verifyToken, verifyTokenTemp } = require("../../middleware");
const {
  AddPropertyValidation,
  PayOnAccessValidation,
  ReportValidation,
} = require("../../validations/PropertyValidation");
const { upload } = require("../../helpers");
const router = express.Router();

router.get("/leaderBoardList", verifyToken, PropertyController.leaderBoard);
router.get(
  "/getUserProperties",
  verifyToken,
  PropertyController.getUserProperties
);
router.get("/getUserPayOnAccessProperties", verifyToken, PropertyController.getBoughtProperties);
router.get("/:id?", verifyTokenTemp, PropertyController.index);
router.get(
  "/getPropertyAnalysis/:id",
  verifyTokenTemp,
  PropertyController.getPropertyAnalysis
);
router.post(
  "/",
  upload.fields([
    { name: "image", maxCount: 10 },
    { name: "video", maxCount: 1 },
  ]),
  verifyToken,
  AddPropertyValidation,
  PropertyController.addProperty
);

router.delete(
  "/deleteImage/:propertyId/:id",
  verifyToken,
  PropertyController.deleteImage
);

router.delete(
  "/deleteProperty/:propertyId",
  verifyToken,
  PropertyController.deleteProperty
);

router.post(
  "/payOnAccess",
  verifyToken,
  PayOnAccessValidation,
  PropertyController.initiatePayment
);

router.post(
  "/report",
  verifyToken,
  ReportValidation,
  PropertyController.report
);

router.post(
  "/lead/:propertyId",
  verifyToken,
  PropertyController.addPropertyLead
);

module.exports = router;
