From 1870970163fad00d5dc209d067228eead933f84a Mon Sep 17 00:00:00 2001 From: Pavel Brui Date: Thu, 4 Apr 2024 10:41:25 +0200 Subject: [PATCH] fixBooking2 --- .../gei-bookings/src/UserMutation/bookService.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/integrations/gei-bookings/src/UserMutation/bookService.ts b/packages/integrations/gei-bookings/src/UserMutation/bookService.ts index 70f3f8d..2718a90 100644 --- a/packages/integrations/gei-bookings/src/UserMutation/bookService.ts +++ b/packages/integrations/gei-bookings/src/UserMutation/bookService.ts @@ -27,16 +27,15 @@ export const bookService = async (input: FieldResolveInput) => bookServices.filter((s): s is WithId => typeof s !== 'string'), bookServices.filter((s): s is string => typeof s === 'string') ]; - bookServices.forEach(async (s) => { - if (typeof s === 'string') { + + if (busy[0]) { await o('Services').collection.updateMany( { _id: { $in: bookedServices.map((s: any) => s._id) } }, { $set: { taken: false } }, ); - throw new GlobalError(`Service is already taken: ${s}`, import.meta.url); + throw new GlobalError(`Service is already taken: ${busy}`, import.meta.url); } - return s._id; - }); + const book = await o('Bookings')