Scheduling infrastructure for absolutely everyone.
fix: get location url from metadata (#6774)
Udit Takkarf60399ca8bd1
diff --git a/apps/web/pages/booking/[uid].tsx b/apps/web/pages/booking/[uid].tsxindex 8fee2fd5df1..bcea85e953d 100644--- a/apps/web/pages/booking/[uid].tsx+++ b/apps/web/pages/booking/[uid].tsx@@ -34,6 +34,7 @@ import { getIs24hClockFromLocalStorage, isBrowserLocale24h } from "@calcom/lib/timport { localStorage } from "@calcom/lib/webstorage";import prisma from "@calcom/prisma";import { Prisma } from "@calcom/prisma/client";+import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";import { Button, EmailInput, HeadSeo } from "@calcom/ui";import { FiX, FiChevronLeft, FiCheck, FiCalendar } from "@calcom/ui/components/icon";@@ -188,16 +189,19 @@ export default function Success(props: SuccessProps) {window.scrollTo(0, document.body.scrollHeight);}- const location: ReturnType<typeof getEventLocationValue> = Array.isArray(props.bookingInfo.location)- ? props.bookingInfo.location[0]+ const location: ReturnType<typeof getEventLocationValue> = props.bookingInfo.location+ ? props.bookingInfo.location: // If there is no location set then we default to Cal Video"integrations:daily";+ const locationVideoCallUrl: string | undefined = bookingMetadataSchema.parse(+ props?.bookingInfo?.metadata || {}+ )?.videoCallUrl;+if (!location) {// Can't use logger.error because it throws error on client. stdout isn't available to it.console.error(`No location found `);}-const status = props.bookingInfo?.status;const reschedule = props.bookingInfo.status === BookingStatus.ACCEPTED;const cancellationReason = props.bookingInfo.cancellationReason;@@ -281,8 +285,8 @@ export default function Success(props: SuccessProps) {function eventLink(): string {const optional: { location?: string } = {};- if (location) {- optional["location"] = location;+ if (locationVideoCallUrl) {+ optional["location"] = locationVideoCallUrl;}const event = createEvent({@@ -332,7 +336,11 @@ export default function Success(props: SuccessProps) {);const customInputs = bookingInfo?.customInputs;- const locationToDisplay = getSuccessPageLocationMessage(location, t);+ const locationToDisplay = getSuccessPageLocationMessage(+ locationVideoCallUrl ? locationVideoCallUrl : location,+ t,+ bookingInfo.status+ );const hasSMSAttendeeAction =eventType.workflows.find((workflowEventType) =>@@ -632,8 +640,8 @@ export default function Success(props: SuccessProps) {.format("YYYYMMDDTHHmmss[Z]")}&text=${eventName}&details=${props.eventType.description}` +- (typeof location === "string"- ? "&location=" + encodeURIComponent(location)+ (typeof locationVideoCallUrl === "string"+ ? "&location=" + encodeURIComponent(locationVideoCallUrl): "") +(props.eventType.recurringEvent? "&recur=" +@@ -661,7 +669,10 @@ export default function Success(props: SuccessProps) {date.utc().format() +"&subject=" +eventName- ) + (location ? "&location=" + location : "")+ ) ++ (locationVideoCallUrl+ ? "&location=" + encodeURIComponent(locationVideoCallUrl)+ : "")}className="mx-2 h-10 w-10 rounded-sm border border-gray-200 px-3 py-2 dark:border-gray-700 dark:text-white"target="_blank">@@ -685,7 +696,10 @@ export default function Success(props: SuccessProps) {date.utc().format() +"&subject=" +eventName- ) + (location ? "&location=" + location : "")+ ) ++ (locationVideoCallUrl+ ? "&location=" + encodeURIComponent(locationVideoCallUrl)+ : "")}className="mx-2 h-10 w-10 rounded-sm border border-gray-200 px-3 py-2 dark:border-gray-700 dark:text-white"target="_blank">@@ -984,6 +998,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {endTime: true,location: true,status: true,+ metadata: true,cancellationReason: true,user: {select: {