diff --git a/app/frontend/src/javascript/controllers/events.js.erb b/app/frontend/src/javascript/controllers/events.js.erb index c55105338..f4e92afe9 100644 --- a/app/frontend/src/javascript/controllers/events.js.erb +++ b/app/frontend/src/javascript/controllers/events.js.erb @@ -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;