const express = require('express');
const router = express.Router();
const discountController = require('../controller/discount.controller');
const { authUser, authAdmin, asyncHandler } = require('../auth/checkAuth');

// User: Áp dụng mã giảm giá
router.post('/apply', authUser, asyncHandler(discountController.apply));

// Admin routes
router.post('/', authAdmin, asyncHandler(discountController.create));
router.get('/', authAdmin, asyncHandler(discountController.getAll));
router.put('/:id', authAdmin, asyncHandler(discountController.update));
router.delete('/:id', authAdmin, asyncHandler(discountController.delete));

module.exports = router;
