Scheduling infrastructure for absolutely everyone.
fix: Embed Snippet Generator, hard crash on reload (#11363)
Hariom Balhara2b1918f40a31
diff --git a/apps/web/pages/_document.tsx b/apps/web/pages/_document.tsxindex 006b73c8fad..f0a6670b43d 100644--- a/apps/web/pages/_document.tsx+++ b/apps/web/pages/_document.tsx@@ -29,7 +29,11 @@ class MyDocument extends Document<Props> {const asPath = ctx.asPath || "";// Use a dummy URL as default so that URL parsing works for relative URLs as well. We care about searchParams and pathname onlyconst parsedUrl = new URL(asPath, "https://dummyurl");- const isEmbed = parsedUrl.pathname.endsWith("/embed") || parsedUrl.searchParams.get("embedType") !== null;+ const isEmbedSnippetGeneratorPath = parsedUrl.pathname.startsWith("/event-types");+ // FIXME: Revisit this logic to remove embedType query param check completely. Ideally, /embed should always be there at the end of the URL. Test properly and then remove it.+ const isEmbed =+ (parsedUrl.pathname.endsWith("/embed") || parsedUrl.searchParams.get("embedType") !== null) &&+ !isEmbedSnippetGeneratorPath;const embedColorScheme = parsedUrl.searchParams.get("ui.color-scheme");const initialProps = await Document.getInitialProps(ctx);return { isEmbed, embedColorScheme, nonce, ...initialProps };diff --git a/packages/features/embed/Embed.tsx b/packages/features/embed/Embed.tsxindex be757d42552..afebad31f03 100644--- a/packages/features/embed/Embed.tsx+++ b/packages/features/embed/Embed.tsx@@ -82,12 +82,6 @@ function useRouterHelpers() {return { goto, removeQueryParams };}-const getQueryParam = (queryParam: string) => {- const params = new URLSearchParams(window.location.search);-- return params.get(queryParam);-};-const ThemeSelectControl = ({ children, ...props }: ControlProps<{ value: Theme; label: string }, false>) => {return (<components.Control {...props}>@@ -526,7 +520,7 @@ const EmbedTypeCodeAndPreviewDialogContent = ({(state) => [state.month, state.selectedDatesAndTimes],shallow);- const eventId = getQueryParam("eventId");+ const eventId = searchParams.get("eventId");const calLink = decodeURIComponent(embedUrl);const { data: eventTypeData } = trpc.viewer.eventTypes.get.useQuery({ id: parseInt(eventId as string) },