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

const kycController = require('../controllers/kycController');
const { authenticate } = require('../middleware/auth');
//const authorizePermissions = require('../middleware/authorization');
const uploadKycDocument = require('../middleware/uploadKycDocument');

router.get('/', authenticate, kycController.getVerificationCenter);
router.get('/status', authenticate, kycController.getVerificationCenter);
router.get('/documents', authenticate, kycController.getDocuments);

router.post('/basic-info', authenticate, kycController.submitBasicInfo);

router.post(
  '/upload',
  authenticate,
  (req, res, next) => {
    uploadKycDocument(req, res, function (err) {
      if (err) return next(err);
      next();
    });
  },
  kycController.uploadDocument
);

router.put('/email/resend', authenticate, kycController.resendEmailVerification);
router.put('/phone/resend', authenticate, kycController.resendPhoneVerification);
router.post('/enhanced/request', authenticate, kycController.requestEnhancedReview);

// admin/compliance only
/* router.put(
  '/submissions/:submissionId/approve',
  authenticate,
  authorizePermissions('admin', 'compliance'),
  kycController.approveSubmission
); */

/* router.put(
  '/submissions/:submissionId/reject',
  authenticate,
  authorizePermissions('admin', 'compliance'),
  kycController.rejectSubmission
); */

module.exports = router;