const express = require('express');
const router = express.Router();
const checklistController = require('../controllers/checklistController');
const { requireAuth, requirePage } = require('../middleware/auth');

router.use(requireAuth);

// Safety checks CRUD
router.get('/', checklistController.getAllChecks);
router.get('/weather-conditions', checklistController.getWeatherConditions);
router.get('/work-types', checklistController.getWorkTypes);
router.get('/tasks/:workTypeId', checklistController.getTasksByWorkType);
router.get('/:id', checklistController.getCheckById);
router.post('/', requirePage('safety_checklist'), checklistController.createCheck);
router.put('/:id', requirePage('safety_checklist'), checklistController.updateCheck);
router.delete('/:id', requirePage('safety_checklist'), checklistController.deleteCheck);

module.exports = router;
