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

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

// Get all incoming inspection reports
router.get('/', incomingInspectionReportController.getAll);

// Get reports by supplier
router.get('/supplier/:supplierId', incomingInspectionReportController.getBySupplier);

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

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

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

// Update
router.put('/:id', incomingInspectionReportController.update);

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

module.exports = router;
