1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-03-21 12:29:03 +01:00

(bug) user cant book event after has reservation canceled

This commit is contained in:
Du Peng 2023-08-31 17:11:18 +02:00
parent 37aa4fb2ff
commit ad89e4f278

View File

@ -238,7 +238,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
$scope.changeNbPlaces = function (priceType) {
let reservedPlaces = 0;
if ($scope.event.event_type === 'family') {
reservedPlaces = $scope.reservations.reduce((sum, reservation) => {
const reservations = $scope.reservations.filter((reservation) => {
return !reservation.slots_reservations_attributes[0].canceled_at;
});
reservedPlaces = reservations.reduce((sum, reservation) => {
return sum + reservation.booking_users_attributes.length;
}, 0);
}
@ -742,7 +745,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
}
}
}
for (const r of $scope.reservations) {
const reservations = $scope.reservations.filter((reservation) => {
return !reservation.slots_reservations_attributes[0].canceled_at;
});
for (const r of reservations) {
for (const user of r.booking_users_attributes) {
const key = user.booked_type === 'User' ? `user_${user.booked_id}` : `child_${user.booked_id}`;
if (key === userKey) {
@ -784,7 +790,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
*/
const updateNbReservePlaces = function () {
if ($scope.event.event_type === 'family' && $scope.ctrl.member.id) {
const reservedPlaces = $scope.reservations.reduce((sum, reservation) => {
const reservations = $scope.reservations.filter((reservation) => {
return !reservation.slots_reservations_attributes[0].canceled_at;
});
const reservedPlaces = reservations.reduce((sum, reservation) => {
return sum + reservation.booking_users_attributes.length;
}, 0);
const maxPlaces = $scope.children.length + 1 - reservedPlaces;