const express = require('express');
const router = express.Router();
const attendanceController = require('../controllers/attendanceController');
const musterRollController = require('../controllers/musterRollController');
const payrollController = require('../controllers/payrollController');
const payslipController = require('../controllers/payslipController');
const { authenticateToken } = require('../middlewares/auth');

// Attendance routes
router.get('/attendance', authenticateToken, attendanceController.getAll);
router.get('/attendance/:id', authenticateToken, attendanceController.getById);
router.post('/attendance', authenticateToken, attendanceController.create);
router.put('/attendance/:id', authenticateToken, attendanceController.update);
router.delete('/attendance/:id', authenticateToken, attendanceController.delete);

// Muster Roll routes
router.get('/muster-roll', authenticateToken, musterRollController.getAll);
router.get('/muster-roll/:id', authenticateToken, musterRollController.getById);
router.post('/muster-roll', authenticateToken, musterRollController.create);
router.put('/muster-roll/:id', authenticateToken, musterRollController.update);
router.delete('/muster-roll/:id', authenticateToken, musterRollController.delete);

// Payroll routes
router.get('/payroll', authenticateToken, payrollController.getAll);
router.get('/payroll/:id', authenticateToken, payrollController.getById);
router.post('/payroll', authenticateToken, payrollController.create);
router.put('/payroll/:id', authenticateToken, payrollController.update);
router.delete('/payroll/:id', authenticateToken, payrollController.delete);

// Payslip routes
router.get('/payslip', authenticateToken, payslipController.getAll);
router.get('/payslip/:id', authenticateToken, payslipController.getById);
router.post('/payslip', authenticateToken, payslipController.create);
router.put('/payslip/:id', authenticateToken, payslipController.update);
router.put('/payslip/:id/status', authenticateToken, payslipController.updateStatus);
router.put('/payslip/:id/mark-downloaded', authenticateToken, payslipController.markDownloaded);

module.exports = router;

