const express = require('express');
const router = express.Router();
const raffleController = require('../controllers/raffleController');

const { verifyUserToken, verifyToken } = require('../middleware/auth');

router.get('/', raffleController.getRaffles);
router.get('/my-tickets', verifyUserToken, raffleController.getMyTickets);
router.get('/tickets', verifyToken, raffleController.getAllTickets);
router.get('/:id', raffleController.getRaffleDetail);
router.get('/:id/result', raffleController.getResult);
router.get('/:id/current-price', raffleController.getCurrentPrice);
router.post('/:id/price-rules', verifyToken, raffleController.addPriceRule);
router.get('/:id/price-rules', verifyToken, raffleController.listPriceRules);
router.get('/:id/discounts', raffleController.getDiscounts);
router.post('/:id/discounts', verifyToken, raffleController.saveDiscounts);
router.get('/:id/flash-promo', raffleController.getFlashPromo);
router.post('/:id/flash-promo', verifyToken, raffleController.createFlashPromo);
router.delete('/:id/flash-promo/:promo_id', verifyToken, raffleController.cancelFlashPromo);
router.get('/:raffle_id/tickets', raffleController.getTickets);
router.post('/', verifyToken, raffleController.createRaffle);
router.post('/:id/draw', verifyToken, raffleController.drawRaffle);
router.post('/ticket', raffleController.buyTicket);
router.get('/order/:id/status', raffleController.getOrderStatus);
router.delete('/ticket/:id', verifyToken, raffleController.deleteTicket);

module.exports = router;
