const express = require('express');
const UserController = require('../controllers/users.controller');
const verifyToken = require('../middleware/verifyToken');
const verifyAccess = require('../middleware/verifyAccess');

const router = express.Router();

router.route('/')
  .get(verifyToken.verifyAccessToken, UserController.getAll)
  .post(verifyToken.verifyAccessToken, verifyAccess(), UserController.create);

router.route('/:id')
  .get(verifyToken.verifyAccessToken, UserController.getById)
  .put(verifyToken.verifyAccessToken, verifyAccess(), UserController.update)
  .delete(verifyToken.verifyAccessToken, verifyAccess(), UserController.delete);

router.route('/change-password/:id')
  .put(verifyToken.verifyAccessToken, verifyAccess(), UserController.changePassword);

router.route('/:id/approve')
  .put(verifyToken.verifyAccessToken, verifyAccess(), UserController.approve);

router.route('/:id/reject')
  .put(verifyToken.verifyAccessToken, verifyAccess(), UserController.reject);

module.exports = router;
