fix: instant booking location lookup (#27517)
Use booking uid instead of numeric id for instant booking location endpoint, aligning with existing booking endpoint patterns
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user