Scheduling infrastructure for absolutely everyone.
fix: instant booking location lookup (#27517)
Pedro Castro1ff307bb4443
diff --git a/apps/web/modules/bookings/hooks/useBookings.ts b/apps/web/modules/bookings/hooks/useBookings.tsindex c87ba5949de..a55433f15b7 100644--- a/apps/web/modules/bookings/hooks/useBookings.ts+++ b/apps/web/modules/bookings/hooks/useBookings.ts@@ -158,13 +158,13 @@ const setInstantCooldownNow = (eventTypeId?: number | null) => {const storeInLocalStorage = ({eventTypeId,expiryTime,- bookingId,+ bookingUid,}: {eventTypeId: number;expiryTime: Date;- bookingId: number;+ bookingUid: string;}) => {- const value = JSON.stringify({ eventTypeId, expiryTime, bookingId });+ const value = JSON.stringify({ eventTypeId, expiryTime, bookingUid });localStorage.setItem(STORAGE_KEY, value);};@@ -194,7 +194,7 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookinconst isRescheduling = !!rescheduleUid && !!bookingData;- const bookingId = parseInt(getQueryParam("bookingId") ?? "0");+ const bookingUid = getQueryParam("bookingUid") ?? "";useEffect(() => {if (!isInstantMeeting) return;@@ -213,7 +213,7 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookinif (parsedInstantBookingInfo) {setExpiryTime(parsedInstantBookingInfo.expiryTime);- updateQueryParam("bookingId", parsedInstantBookingInfo.bookingId);+ updateQueryParam("bookingUid", parsedInstantBookingInfo.bookingUid);}}}, [eventTypeId, isInstantMeeting]);@@ -222,10 +222,10 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookinconst _instantBooking = trpc.viewer.bookings.getInstantBookingLocation.useQuery({- bookingId: bookingId,+ bookingUid: bookingUid,},{- enabled: !!bookingId,+ enabled: !!bookingUid,refetchInterval: 2000,refetchIntervalInBackground: true,}@@ -421,12 +421,12 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookinstoreInLocalStorage({eventTypeId,expiryTime: responseData.expires,- bookingId: responseData.bookingId,+ bookingUid: responseData.bookingUid,});setInstantCooldownNow(eventTypeId);}- updateQueryParam("bookingId", responseData.bookingId);+ updateQueryParam("bookingUid", responseData.bookingUid);setExpiryTime(responseData.expires);},onError: (err) => {diff --git a/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.handler.ts b/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.handler.tsindex f1e808ef349..8faeaabc36d 100644--- a/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.handler.ts+++ b/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.handler.ts@@ -12,11 +12,11 @@ type GetOptions = {export const getHandler = async ({ ctx, input }: GetOptions) => {const { prisma } = ctx;- const { bookingId } = input;+ const { bookingUid } = input;const booking = await prisma.booking.findUnique({where: {- id: bookingId,+ uid: bookingUid,status: BookingStatus.ACCEPTED,},select: {diff --git a/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.schema.ts b/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.schema.tsindex f7d10a5fce6..9c8910a7819 100644--- a/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.schema.ts+++ b/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.schema.ts@@ -1,9 +1,9 @@import { z } from "zod";export type TInstantBookingInputSchema = {- bookingId: number;+ bookingUid: string;};export const ZInstantBookingInputSchema: z.ZodType<TInstantBookingInputSchema> = z.object({- bookingId: z.number(),+ bookingUid: z.string(),});