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

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

// Get all welding final inspection reports
router.get('/', weldingFinalInspectionReportController.getAll);

// Get reports by customer
router.get('/customer/:customerId', weldingFinalInspectionReportController.getByCustomer);

// Work order helpers
router.get('/work-order-options', weldingFinalInspectionReportController.getWorkOrderOptions);
router.get('/work-order-prefill/:workOrderId', weldingFinalInspectionReportController.getWorkOrderPrefill);

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

// Get by ID
router.get('/:id', weldingFinalInspectionReportController.getById);

// Create
router.post('/', weldingFinalInspectionReportController.create);

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

// Delete
router.delete('/:id', weldingFinalInspectionReportController.delete);

module.exports = router;
