fix: rescheduling dynamic booking (#10597)

Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
This commit is contained in:
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

View File

@ -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);