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

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

// Get all customer complaint registers
router.get('/', customerComplaintRegisterController.getAll);

// Get complaints by customer
router.get('/customer/:customerId', customerComplaintRegisterController.getByCustomer);

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

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

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

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

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

module.exports = router;
