From ce476bf90fe67c0ff4ab85a8a62da35f610ace9d Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Wed, 13 Apr 2022 22:52:27 +0530 Subject: [PATCH] Consider Pending/Accepted bookings only (#2479) Co-authored-by: Bailey Pumfleet --- apps/web/pages/api/book/event.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.ts index ec99dfca..79f7f43c 100644 --- a/apps/web/pages/api/book/event.ts +++ b/apps/web/pages/api/book/event.ts @@ -458,11 +458,26 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) }); const credentials = currentUser.credentials; + const calendarBusyTimes: EventBusyDate[] = await prisma.booking .findMany({ where: { - userId: currentUser.id, - eventTypeId: eventTypeId, + AND: [ + { + userId: currentUser.id, + eventTypeId: eventTypeId, + }, + { + OR: [ + { + status: "ACCEPTED", + }, + { + status: "PENDING", + }, + ], + }, + ], }, }) .then((bookings) => bookings.map((booking) => ({ end: booking.endTime, start: booking.startTime })));