const express = require('express');
const router = express.Router();
const {
	createHotelReview,
	getHotelReviews,
	updateHotelReview,
	deleteHotelReview,
	getRoomReviews,
} = require('../../controllers/members/hotel-reviews');
const { memberAuth, validation } = require('../../middlewares');
const { body } = require('express-validator');

router.get('/:id', getHotelReviews);
router.get('/room/:id', getRoomReviews);

router.post(
	'/',
	memberAuth,
	[
		body('bookingId').notEmpty().withMessage('bookingId is required'),
		body('rating').isInt({ min: 1, max: 5 }).withMessage('rating must be an integer between 1 and 5'),
		validation,
	],
	createHotelReview,
);
router.patch(
	'/',
	[
		body('reviewId').notEmpty().withMessage('reviewId is required'),
		body('rating').optional().isInt({ min: 1, max: 5 }).withMessage('rating must be an integer between 1 and 5'),
		validation,
	],
	memberAuth,
	updateHotelReview,
);
router.delete('/:id', memberAuth, deleteHotelReview);

module.exports = router;
