fix: rescheduling dynamic booking (#10597)

Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
pull/10593/head^2
Leo Giovanetti 2023-08-08 15:51:54 -03:00 committed by GitHub
parent 0d1ab6ade9
commit 382cbe0a86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 14 deletions

View File

@ -109,24 +109,20 @@ export const getBookingWithResponses = <
export default getBooking; export default getBooking;
export const getBookingForReschedule = async (uid: string) => { export const getBookingForReschedule = async (uid: string) => {
let eventTypeId: number | null = null;
let rescheduleUid: string | null = null; let rescheduleUid: string | null = null;
eventTypeId = const theBooking = await prisma.booking.findFirst({
( where: {
await prisma.booking.findFirst({ uid,
where: { },
uid, select: {
}, id: true,
select: { },
eventTypeId: true, });
},
})
)?.eventTypeId || null;
// If no booking is found via the uid, it's probably a booking seat, // If no booking is found via the uid, it's probably a booking seat,
// which we query next. // which we query next.
let attendeeEmail: string | null = null; let attendeeEmail: string | null = null;
if (!eventTypeId) { if (!theBooking) {
const bookingSeat = await prisma.bookingSeat.findFirst({ const bookingSeat = await prisma.bookingSeat.findFirst({
where: { where: {
referenceUid: uid, 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, // If we don't have a booking and no rescheduleUid, the ID is invalid,
// and we return null here. // and we return null here.
if (!eventTypeId && !rescheduleUid) return null; if (!theBooking && !rescheduleUid) return null;
const booking = await getBooking(prisma, rescheduleUid || uid); const booking = await getBooking(prisma, rescheduleUid || uid);