Scheduling infrastructure for absolutely everyone.
fix: instant meeting fixes (#14214)
Udit Takkar452ea6a993bd
diff --git a/packages/app-store/dailyvideo/lib/VideoApiAdapter.ts b/packages/app-store/dailyvideo/lib/VideoApiAdapter.tsindex 3c2aa548ac7..97c36059e72 100644--- a/packages/app-store/dailyvideo/lib/VideoApiAdapter.ts+++ b/packages/app-store/dailyvideo/lib/VideoApiAdapter.ts@@ -158,6 +158,7 @@ const DailyVideoApiAdapter = (): VideoApiAdapter => {enable_chat: true,exp: exp,enable_recording: "cloud",+ start_video_off: true,},};diff --git a/packages/features/bookings/Booker/Booker.tsx b/packages/features/bookings/Booker/Booker.tsxindex 36eff862553..d87ba27de1a 100644--- a/packages/features/bookings/Booker/Booker.tsx+++ b/packages/features/bookings/Booker/Booker.tsx@@ -116,7 +116,7 @@ const BookerComponent = ({const { bookerFormErrorRef, key, formEmail, bookingForm, errors: formErrors } = bookerForm;- const { handleBookEvent, errors, loadingStates, expiryTime } = bookings;+ const { handleBookEvent, errors, loadingStates, expiryTime, instantVideoMeetingUrl } = bookings;const {isEmailVerificationModalVisible,@@ -181,6 +181,7 @@ const BookerComponent = ({<RedirectToInstantMeetingModalexpiryTime={expiryTime}bookingId={parseInt(getQueryParam("bookingId") || "0")}+ instantVideoMeetingUrl={instantVideoMeetingUrl}onGoBack={() => {onGoBackInstantMeeting();}}@@ -193,6 +194,7 @@ const BookerComponent = ({);}, [bookerFormErrorRef,+ instantVideoMeetingUrl,bookerState,bookingForm,errors,diff --git a/packages/features/bookings/Booker/components/RedirectToInstantMeetingModal.tsx b/packages/features/bookings/Booker/components/RedirectToInstantMeetingModal.tsxindex 44fc386f912..6311a039b5e 100644--- a/packages/features/bookings/Booker/components/RedirectToInstantMeetingModal.tsx+++ b/packages/features/bookings/Booker/components/RedirectToInstantMeetingModal.tsx@@ -1,3 +1,4 @@+import { useRouter } from "next/navigation";import { useState, useEffect } from "react";import dayjs from "@calcom/dayjs";@@ -15,14 +16,17 @@ export const RedirectToInstantMeetingModal = ({bookingId,onGoBack,expiryTime,+ instantVideoMeetingUrl,}: {bookingId: number;onGoBack: () => void;expiryTime?: Date;+ instantVideoMeetingUrl?: string;}) => {const { t } = useLocale();const [timeRemaining, setTimeRemaining] = useState(calculateTimeRemaining());const [hasInstantMeetingTokenExpired, setHasInstantMeetingTokenExpired] = useState(false);+ const router = useRouter();function calculateTimeRemaining() {const now = dayjs();@@ -53,7 +57,7 @@ export const RedirectToInstantMeetingModal = ({};useEffect(() => {- if (!expiryTime || hasInstantMeetingTokenExpired) {+ if (!expiryTime || hasInstantMeetingTokenExpired || !!instantVideoMeetingUrl) {window.removeEventListener("beforeunload", handleBeforeUnload);return;}@@ -62,7 +66,14 @@ export const RedirectToInstantMeetingModal = ({return () => {window.removeEventListener("beforeunload", handleBeforeUnload);};- }, [expiryTime, hasInstantMeetingTokenExpired]);+ }, [expiryTime, hasInstantMeetingTokenExpired, instantVideoMeetingUrl]);++ useEffect(() => {+ if (!!instantVideoMeetingUrl) {+ window.removeEventListener("beforeunload", handleBeforeUnload);+ router.push(instantVideoMeetingUrl);+ }+ }, [instantVideoMeetingUrl]);return (<Dialog open={!!bookingId && !!expiryTime}>diff --git a/packages/features/bookings/Booker/components/hooks/useBookings.ts b/packages/features/bookings/Booker/components/hooks/useBookings.tsindex 2e24ce3e2c4..fd28433348b 100644--- a/packages/features/bookings/Booker/components/hooks/useBookings.ts+++ b/packages/features/bookings/Booker/components/hooks/useBookings.ts@@ -49,6 +49,7 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata }: IUseBoconst bookingSuccessRedirect = useBookingSuccessRedirect();const bookerFormErrorRef = useRef<HTMLDivElement>(null);const [instantMeetingTokenExpiryTime, setExpiryTime] = useState<Date | undefined>();+ const [instantVideoMeetingUrl, setInstantVideoMeetingUrl] = useState<string | undefined>();const duration = useBookerStore((state) => state.selectedDuration);const isRescheduling = !!rescheduleUid && !!bookingData;@@ -71,14 +72,12 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata }: IUseBoif (!data) return;try {- showToast(t("something_went_wrong_on_our_end"), "error");-const locationVideoCallUrl: string | undefined = bookingMetadataSchema.parse(data.booking?.metadata || {})?.videoCallUrl;if (locationVideoCallUrl) {- router.push(locationVideoCallUrl);+ setInstantVideoMeetingUrl(locationVideoCallUrl);} else {showToast(t("something_went_wrong_on_our_end"), "error");}@@ -254,5 +253,6 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata }: IUseBobookerFormErrorRef,errors,loadingStates,+ instantVideoMeetingUrl,};};diff --git a/packages/features/instant-meeting/handleInstantMeeting.ts b/packages/features/instant-meeting/handleInstantMeeting.tsindex 8e0d78f08ca..c148422c2bc 100644--- a/packages/features/instant-meeting/handleInstantMeeting.ts+++ b/packages/features/instant-meeting/handleInstantMeeting.ts@@ -132,7 +132,6 @@ async function handler(req: NextApiRequest) {throw new Error("Cal Video Meeting Creation Failed");}- eventType.team.id;const bookingReferenceToCreate = [{type: calVideoMeeting.type,@@ -201,7 +200,6 @@ async function handler(req: NextApiRequest) {});// Trigger Webhook-const webhookData = {triggerEvent: WebhookTriggerEvents.INSTANT_MEETING,uid: newBooking.uid,diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsxindex d3299715f7e..5244020632d 100644--- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx+++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx@@ -269,6 +269,7 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>creatingRecurringBooking: creatingRecBooking,creatingInstantBooking: creatingInstantBooking,},+ instantVideoMeetingUrl: undefined,}}slots={slots}calendars={{