// apps/api/src/routes/leads.routes.js

const express = require('express');
const router = express.Router();
const leadsController = require('../controllers/leads.controller');
const authMiddleware = require('../middleware/auth.middleware');
const checkLeadAccess = require('../middleware/checkLeadAccess');

// Apply lead access middleware to GET endpoints
router.get('/', authMiddleware, checkLeadAccess, leadsController.getLeads);
router.get('/:id', authMiddleware, leadsController.getLead);
router.post('/:id/feedback', authMiddleware, leadsController.submitFeedback);

// Export endpoints - restrict to pro users only
router.get('/export/csv', authMiddleware, leadsController.exportCSV);
router.get('/export/json', authMiddleware, leadsController.exportJSON);

module.exports = router;