const express = require('express');
const { getAllEvents, getEvent } = require('../../controllers/members/events');
const { body } = require('express-validator');
const { validation, memberAuth } = require('../../middlewares');
const {
	registerForEvent,
	getMyRegistrations,
	getMyRegistration,
	payRegistration,
} = require('../../controllers/members/event-registrations');

const router = express.Router();

router.post(
	'/registrations',
	memberAuth,
	[body('eventId').notEmpty().withMessage('Event ID is required'), validation],
	registerForEvent,
);

router.post('/registrations/pay', [body('registrationId').notEmpty(), validation], payRegistration);

router.get('/registrations/', memberAuth, getMyRegistrations);
router.get('/registrations/:id', memberAuth, getMyRegistration);

router.get('/', getAllEvents);
router.get('/:id', getEvent);

// router.put('/:id/cancel', memberAuth, cancelRegistration);

module.exports = router;
