Skip to content

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.ts
index 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, isBookin
const 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, isBookin
if (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, isBookin
const _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, isBookin
storeInLocalStorage({
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.ts
index 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.ts
index 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(),
});