const express = require('express')
const { createProject, createProjectValidationRules } = require('../../../controllers/application/projects/createProjectController')
const { getProjects, getSingleProjects, getSingleProjectsWeb, getUserProjects, getUserProjectsWeb } = require('../../../controllers/application/projects/getProjectController')
const { getProjectTypes } = require('../../../controllers/application/projects/projectTypesController')
const { initiatePayment, handlePaymentCallback, paymentRequestStepOne, paymentRequestStepTwo, paymentRequestStepAll, paymentRequestStepOneCallback, paymentRequestStepTwoCallback, paymentRequestStepAllCallback, handleSuccessfulPayment, handleFailedPayment } = require('../../../controllers/application/payment/paymentController')
const auth = require('../../../middlewares/auth')
const { requestProjectValidationRules, requestProject, acceptProject, editRequestProject } = require('../../../controllers/application/projects/requestProjectController')
const { editProject, doneProject, cancleProject, editProjectValidationRules, setRateProject, doneProjectWeb } = require('../../../controllers/application/projects/updateProjectController')
const blockCheck = require('../../../middlewares/blockCheck')
const isRegister = require('../../../middlewares/isRegister')
const { initiatePaymentWeb, handlePaymentCallbackWeb, paymentRequestAcceptWeb } = require('../../../controllers/application/payment/paymentControllerWeb')
const router = express.Router()
router.get('/', getProjects)
router.get('/user-projects', [auth], getUserProjects)
router.get('/user-projects/web', getUserProjectsWeb)
router.get('/types', [auth], getProjectTypes)
router.get('/get/:projectId', [auth], getSingleProjects)
router.get('/get/web/:projectId', getSingleProjectsWeb)
router.get('/payment', handlePaymentCallback)
router.get('/payment-web', handlePaymentCallbackWeb)
router.post('/create', [blockCheck], [auth], [isRegister], createProjectValidationRules(), createProject)
router.post('/edit', [blockCheck], [auth], [isRegister], editProjectValidationRules(), editProject)
router.post('/rate', [blockCheck], [auth], [isRegister], setRateProject)
router.post('/initiate-payment', [blockCheck], [isRegister], [auth], initiatePayment)
router.post('/initiate-payment-web', [blockCheck], [isRegister], [auth], initiatePaymentWeb)
router.post('/request', [blockCheck], [isRegister], [auth], requestProjectValidationRules(), requestProject)
router.post('/edit-request', [isRegister], [blockCheck], [auth], requestProjectValidationRules(), editRequestProject)
router.post('/payment-request-step-one', [isRegister], [blockCheck], [auth], paymentRequestStepOne)
router.post('/payment-request-step-one/web', [isRegister], [blockCheck], [auth], paymentRequestAcceptWeb)
router.post('/payment-request-step-two', [isRegister], [blockCheck], [auth], paymentRequestStepTwo)
router.post('/payment-request-all', [isRegister], [blockCheck], [auth], paymentRequestStepAll)
router.get('/payment-request-step-one-callback', paymentRequestStepOneCallback)
router.get('/payment-request-step-two-callback', paymentRequestStepTwoCallback)
router.get('/payment-request-step-all-callback', paymentRequestStepAllCallback)
router.post('/accept', [isRegister], [blockCheck], [auth], acceptProject)
router.post('/done', [isRegister], [auth], doneProject)
router.post('/done/web', [isRegister], [auth], doneProjectWeb)
router.post('/cancle', [isRegister], [blockCheck], [auth], cancleProject)

// Route for handling successful payment
router.post('/payment-success', handleSuccessfulPayment)
// Route for handling failed payment
router.post('/payment-failed', handleFailedPayment)
module.exports = router
