Skip to content

Commit

Permalink
fix accepted dispo if removed
Browse files Browse the repository at this point in the history
  • Loading branch information
keery committed May 27, 2021
1 parent 99612dd commit a62ee42
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
18 changes: 10 additions & 8 deletions back/api/booking/models/booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ const updateDispo = (dispos = [], status) => {
if (status === "available") {
data.booking = null;
}
dispos.map((dispo) => {
strapi.query("disponibility").update({ id: dispo.id }, data);
if (status === "available") {
strapi
.query("disponibility")
.create({ ...dispo, place: null, status: "canceled" });
}
});
dispos
.filter((dispo) => dispo.status !== "removed")
.map((dispo) => {
strapi.query("disponibility").update({ id: dispo.id }, data);
if (status === "available") {
strapi
.query("disponibility")
.create({ ...dispo, place: null, status: "canceled" });
}
});
};

const getDispoEmail = (dispos = []) => {
Expand Down
1 change: 1 addition & 0 deletions back/api/booking/services/booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const isPast = require("date-fns/isPast");

module.exports = {
async checkIsPast(booking) {
if (!booking.disponibilities) return booking;
if (
booking.status === "pending" &&
isPast(min(booking.disponibilities.map((dispo) => new Date(dispo.start))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "05/27/2021 3:44:21 PM"
"x-generation-date": "05/27/2021 3:56:48 PM"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down
1 change: 1 addition & 0 deletions web/components/Account/Booking/BookingDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ const BookingDrawer = ({ bookingId, setSelected, type }: Props) => {
/>
</Box>
{![
'expired',
'requestcanceled',
'requestcanceledbyplace',
'bookingcanceledbyplace',
Expand Down

0 comments on commit a62ee42

Please sign in to comment.