Skip to content

Commit 1ff307b

Browse files
authored
fix: instant booking location lookup (calcom#27517)
Use booking uid instead of numeric id for instant booking location endpoint, aligning with existing booking endpoint patterns
1 parent c43c48b commit 1ff307b

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

apps/web/modules/bookings/hooks/useBookings.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ const setInstantCooldownNow = (eventTypeId?: number | null) => {
158158
const storeInLocalStorage = ({
159159
eventTypeId,
160160
expiryTime,
161-
bookingId,
161+
bookingUid,
162162
}: {
163163
eventTypeId: number;
164164
expiryTime: Date;
165-
bookingId: number;
165+
bookingUid: string;
166166
}) => {
167-
const value = JSON.stringify({ eventTypeId, expiryTime, bookingId });
167+
const value = JSON.stringify({ eventTypeId, expiryTime, bookingUid });
168168
localStorage.setItem(STORAGE_KEY, value);
169169
};
170170

@@ -194,7 +194,7 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookin
194194

195195
const isRescheduling = !!rescheduleUid && !!bookingData;
196196

197-
const bookingId = parseInt(getQueryParam("bookingId") ?? "0");
197+
const bookingUid = getQueryParam("bookingUid") ?? "";
198198

199199
useEffect(() => {
200200
if (!isInstantMeeting) return;
@@ -213,7 +213,7 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookin
213213

214214
if (parsedInstantBookingInfo) {
215215
setExpiryTime(parsedInstantBookingInfo.expiryTime);
216-
updateQueryParam("bookingId", parsedInstantBookingInfo.bookingId);
216+
updateQueryParam("bookingUid", parsedInstantBookingInfo.bookingUid);
217217
}
218218
}
219219
}, [eventTypeId, isInstantMeeting]);
@@ -222,10 +222,10 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookin
222222

223223
const _instantBooking = trpc.viewer.bookings.getInstantBookingLocation.useQuery(
224224
{
225-
bookingId: bookingId,
225+
bookingUid: bookingUid,
226226
},
227227
{
228-
enabled: !!bookingId,
228+
enabled: !!bookingUid,
229229
refetchInterval: 2000,
230230
refetchIntervalInBackground: true,
231231
}
@@ -421,12 +421,12 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookin
421421
storeInLocalStorage({
422422
eventTypeId,
423423
expiryTime: responseData.expires,
424-
bookingId: responseData.bookingId,
424+
bookingUid: responseData.bookingUid,
425425
});
426426
setInstantCooldownNow(eventTypeId);
427427
}
428428

429-
updateQueryParam("bookingId", responseData.bookingId);
429+
updateQueryParam("bookingUid", responseData.bookingUid);
430430
setExpiryTime(responseData.expires);
431431
},
432432
onError: (err) => {

packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ type GetOptions = {
1212

1313
export const getHandler = async ({ ctx, input }: GetOptions) => {
1414
const { prisma } = ctx;
15-
const { bookingId } = input;
15+
const { bookingUid } = input;
1616

1717
const booking = await prisma.booking.findUnique({
1818
where: {
19-
id: bookingId,
19+
uid: bookingUid,
2020
status: BookingStatus.ACCEPTED,
2121
},
2222
select: {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { z } from "zod";
22

33
export type TInstantBookingInputSchema = {
4-
bookingId: number;
4+
bookingUid: string;
55
};
66

77
export const ZInstantBookingInputSchema: z.ZodType<TInstantBookingInputSchema> = z.object({
8-
bookingId: z.number(),
8+
bookingUid: z.string(),
99
});

0 commit comments

Comments
 (0)