From 382cbe0a862a6fbddef2258e3a95d8a4f5cec525 Mon Sep 17 00:00:00 2001 From: Leo Giovanetti Date: Tue, 8 Aug 2023 15:51:54 -0300 Subject: [PATCH] fix: rescheduling dynamic booking (#10597) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Omar López Co-authored-by: Keith Williams --- packages/features/bookings/lib/get-booking.ts | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/features/bookings/lib/get-booking.ts b/packages/features/bookings/lib/get-booking.ts index 13fa92b6c0..de59f57c26 100644 --- a/packages/features/bookings/lib/get-booking.ts +++ b/packages/features/bookings/lib/get-booking.ts @@ -109,24 +109,20 @@ export const getBookingWithResponses = < export default getBooking; export const getBookingForReschedule = async (uid: string) => { - let eventTypeId: number | null = null; let rescheduleUid: string | null = null; - eventTypeId = - ( - await prisma.booking.findFirst({ - where: { - uid, - }, - select: { - eventTypeId: true, - }, - }) - )?.eventTypeId || null; + const theBooking = await prisma.booking.findFirst({ + where: { + uid, + }, + select: { + id: true, + }, + }); // If no booking is found via the uid, it's probably a booking seat, // which we query next. let attendeeEmail: string | null = null; - if (!eventTypeId) { + if (!theBooking) { const bookingSeat = await prisma.bookingSeat.findFirst({ where: { referenceUid: uid, @@ -154,7 +150,7 @@ export const getBookingForReschedule = async (uid: string) => { // If we don't have a booking and no rescheduleUid, the ID is invalid, // and we return null here. - if (!eventTypeId && !rescheduleUid) return null; + if (!theBooking && !rescheduleUid) return null; const booking = await getBooking(prisma, rescheduleUid || uid);