fix: Embed Snippet Generator, hard crash on reload (#11363)
Co-authored-by: Peer Richelsen <peeroke@gmail.com>11576-cal-2537-a11y-turn-booking-entries-in-booking-to-links-not-clickable-divs^2
parent
fb2c966e6c
commit
2b1918f40a
|
@ -29,7 +29,11 @@ class MyDocument extends Document<Props> {
|
||||||
const asPath = ctx.asPath || "";
|
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 only
|
// Use a dummy URL as default so that URL parsing works for relative URLs as well. We care about searchParams and pathname only
|
||||||
const parsedUrl = new URL(asPath, "https://dummyurl");
|
const 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 embedColorScheme = parsedUrl.searchParams.get("ui.color-scheme");
|
||||||
const initialProps = await Document.getInitialProps(ctx);
|
const initialProps = await Document.getInitialProps(ctx);
|
||||||
return { isEmbed, embedColorScheme, nonce, ...initialProps };
|
return { isEmbed, embedColorScheme, nonce, ...initialProps };
|
||||||
|
|
|
@ -82,12 +82,6 @@ function useRouterHelpers() {
|
||||||
return { goto, removeQueryParams };
|
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>) => {
|
const ThemeSelectControl = ({ children, ...props }: ControlProps<{ value: Theme; label: string }, false>) => {
|
||||||
return (
|
return (
|
||||||
<components.Control {...props}>
|
<components.Control {...props}>
|
||||||
|
@ -526,7 +520,7 @@ const EmbedTypeCodeAndPreviewDialogContent = ({
|
||||||
(state) => [state.month, state.selectedDatesAndTimes],
|
(state) => [state.month, state.selectedDatesAndTimes],
|
||||||
shallow
|
shallow
|
||||||
);
|
);
|
||||||
const eventId = getQueryParam("eventId");
|
const eventId = searchParams.get("eventId");
|
||||||
const calLink = decodeURIComponent(embedUrl);
|
const calLink = decodeURIComponent(embedUrl);
|
||||||
const { data: eventTypeData } = trpc.viewer.eventTypes.get.useQuery(
|
const { data: eventTypeData } = trpc.viewer.eventTypes.get.useQuery(
|
||||||
{ id: parseInt(eventId as string) },
|
{ id: parseInt(eventId as string) },
|
||||||
|
|
Loading…
Reference in New Issue