const { Router } = require('express')
const router = Router()
const userController = require('../controllers/userController')
const ticketsController = require('../controllers/ticketsController')
const representationController = require('../controllers/representationController')
const transactionDraftsController = require('../controllers/transactionDraftsController')
const transactionController = require('../controllers/transactionController')
const surveyController = require('../controllers/surveyController')

/// // profile
router.put('/update_profile', userController.update_user)
router.put('/update_password', userController.update_user_password)
router.put('/changeEmail', userController.changeEmail)
router.post('/resendEmailConfirmation', userController.resendEmailConfirmation)
router.put('/confirmEmail', userController.confirmEmail)
router.put('/changeMobile', userController.changeMobile)
router.post('/resendMobileConfirmation', userController.resendMobileConfirmation)
router.put('/confirmMobile', userController.confirmMobile)

/// // transactions
router.post('/transaction', transactionController.add_transaction)
router.get('/transactions', transactionController.get_all_transactions_for_user)
router.get('/transaction/:ttn', transactionController.get_one_transaction_for_user)

/// /// transaction drafts
router.post('/transactionDraft', transactionDraftsController.add_transaction_draft)
router.get('/transactionDrafts', transactionDraftsController.get_user_drafts)
router.get('/transactionDraft/:draftId', transactionDraftsController.get_one_user_draft)
router.put('/transactionDraft/:draftId', transactionDraftsController.update_draft_description)
router.delete('/transactionDraft/:draftId', transactionDraftsController.remove_draft)

router.put('/transactionDraftItemAdd/:draftId', transactionDraftsController.add_stuff_to_draft)
router.put('/transactionDraftItemRemove/:draftId', transactionDraftsController.remove_stuff_from_draft)

/// // tickets
router.get('/ticketConversations', ticketsController.get_all_tickets)
router.get('/getTicket/:id', ticketsController.get_one_ticket)
router.post('/addTicketConversation', ticketsController.add_ticket)
router.post('/addMessageToTicket/:id', ticketsController.add_message_to_ticket)

/// // representation
router.post('/representation', representationController.add_representation)
router.put('/representation/:representation_id', representationController.edit_representation_by_user)
router.post('/checkRepresentation', representationController.check_representation)
router.post('/representationImages/:representation_code', representationController.upload_image_to_representation)
router.delete(
  '/representationImages/:representation_code/:imgId',
  representationController.remove_image_from_representation
)
router.get('/representation/:id', representationController.getLastUserRep)

/// // survey
router.post('/survey', surveyController.create)
router.get('/surveys', surveyController.getAllForUser)

module.exports = router
