const express = require('express');
const router = express.Router();
const { authenticate } = require('../middlewares/auth');
const dimensionalReportController = require('../controllers/dimensionalReportController');
const dimensionalReportPDFController = require('../controllers/dimensionalReportPDFController');

// All routes require authentication
router.use(authenticate);

// Get all dimensional reports
router.get('/', dimensionalReportController.getAll);

// Work order prefill helpers (must be before /:id)
router.get('/work-order-options', dimensionalReportController.getWorkOrderOptions);
router.get('/work-order-prefill/:workOrderId', dimensionalReportController.getWorkOrderPrefill);

// Get PDF (must be before /:id to avoid route conflict)
router.get('/:id/pdf', dimensionalReportPDFController.generatePDF);

// Get single dimensional report
router.get('/:id', dimensionalReportController.getById);

// Create dimensional report
router.post('/', dimensionalReportController.create);

// Update dimensional report
router.put('/:id', dimensionalReportController.update);
router.patch('/:id/status', dimensionalReportController.updateStatus);

// Delete dimensional report
router.delete('/:id', dimensionalReportController.delete);

module.exports = router;
