const express = require('express');
const {
  getAllLeads,
  getLead,
  createLead,
  updateLead,
  updateLeadStatus,
  deleteLead,
  submitLead,
  reviewLead,
  verifyLead,
  getLeadStats,
  assignLead,
  getUnseenCount
} = require('../controllers/leadController');
const { protect } = require('../middleware/auth');
const { checkModulePermission } = require('../middleware/checkPermission');

const router = express.Router();

router.use(protect);

router.get('/unseen-count', getUnseenCount);
router.get('/stats', /*checkModulePermission('leads', 'read'),*/ getLeadStats);
router.get('/', /*checkModulePermission('leads', 'read'),*/ getAllLeads);
router.get('/:id', /*checkModulePermission('leads', 'read'),*/ getLead);
router.post('/', /*checkModulePermission('leads', 'create'),*/ createLead);
// router.post('/:id/submit', checkModulePermission('workflow', 'create'), submitLead);
// router.post('/:id/review', checkModulePermission('workflow', 'review'), reviewLead);
// router.post('/:id/verify', checkModulePermission('workflow', 'approve'), verifyLead);
// router.post('/:id/assign', checkModulePermission('leads', 'assign'), assignLead);
router.put('/:id', /*checkModulePermission('leads', 'edit'),*/ updateLead);
router.patch('/:id/status', updateLeadStatus);
router.delete('/:id', /*checkModulePermission('leads', 'delete'),*/ deleteLead);

module.exports = router;