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

const userController = require("../controllers/user");
const requestFormController = require("../controllers/requestForm");
const discussionFormController = require("../controllers/discussionForm");
const favoriteController = require("../controllers/favorite");
const reviewController = require("../controllers/review");
const serviceController = require("../controllers/service");
const paymentController = require("../controllers/payment");
const auth = require("../middleware/auth");

// User Auth Routes
router.post("/user/signup", auth.userUpload.array("license", 4),userController.signup);
router.post("/user/verifyOTP", userController.verifyOTP);
router.post("/user/login", userController.login);
router.post("/user/googleLogin", userController.googleLogin);
router.post("/user/setUserType", auth.verifyUser , userController.setUserType);
router.get("/user/getProfile", userController.userProfile);
router.post("/user/updateUser", auth.userUpload.fields([
    {name: "profileImage", maxCount: 1},
    {name: "portfolio", maxCount: 4},
    {name: "license", maxCount: 4}
    ]) , userController.updateUser);
router.get("/user/getAllUsers", userController.getAllUsers);
router.get("/user/nearbyUsers", userController.nearbyUsers);
router.post("/user/forgetPassword", userController.forgetPassword);
router.get("/user/verifyOTPForPassword", userController.verifyOTPForPassword);
router.post("/user/resetPassword", userController.resetPasswrod);

// Service Rouets
router.get("/user/getAllServices", serviceController.getAllServices);

// Request Form Routes
router.post("/user/createRequestForm", requestFormController.createRequestForm);
router.get("/user/getRequestFormById", requestFormController.getRequestFormById);
router.get("/user/getAllRequestForms", requestFormController.getAllRequestForms);
router.post("/user/updateRequestForm", requestFormController.updateRequestForm);
router.post("/user/deleteRequestForm", requestFormController.deleteRequestForm);

// Discussion Form Routes
router.post("/user/createDiscussionForm", discussionFormController.createDiscussionForm);
router.get("/user/getDiscussionFormById", discussionFormController.getAllDiscussionForms);
router.get("/user/getAllDiscussionForms", discussionFormController.getAllDiscussionForms);
router.post("/user/updateDiscussionForm", discussionFormController.updateDiscussionForm);
router.post("/user/deleteDiscussionForm", discussionFormController.deleteDiscussionForm);

// Favorites Routes
router.post("/user/addToFavorites", favoriteController.addToFavorite);
router.get("/user/getAllFavorites", favoriteController.getAllFavorites);

// Review Routes
router.post("/user/addReview", reviewController.addReview);
router.get("/user/getReviewById", reviewController.getReviewById);
router.get("/user/getAllReviews", reviewController.getAllReviews);
router.post("/user/updateReview", reviewController.updateReview);
router.post("/user/deleteReview", reviewController.deleteReview);

//payment
router.post("/user/createSetupIntent" , auth.verifyUser , paymentController.createSetupIntent)
router.post("/user/savePaymentMethod" , paymentController.savePaymentMethod)
router.post("/user/createPayment" , paymentController.createPayment)
router.get("/user/getSavedCards" , auth.verifyUser , paymentController.getSavedCards)

module.exports = router;