* Added embed files for new booker routes. * Updated nextjs config to redirect to correct embed url. * Notify embed of booker size after animation completes. * Don't use animations and 100vh in embed. * Added booker layout toggles to embed settings (wip) * Booker header positioning tweaks * Show correct layout in embed * Don't show pricing event meta if stripe app is not installed * Support custom border booker for embed * wip on passing layout prop to iframe for previews * Only show booker layout settings in embed-create-popup if booker layout feature is enabled. * Made layout prop in preview state for embed optional * Made layout prop in preview state for embed optional * Get layout toggle working * Fixed types * Added themebasis prop * Fix potential circular import that should then fix type errors * Fixed type error by fixing casing. * Type fixes * Added translations * More translations * Remove comment * Removed uneccessary addition to package.json * Removed todo since it's solved in another way --------- Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import type { GetServerSideProps, GetServerSidePropsContext, GetServerSidePropsResult } from "next";
|
|
|
|
export type EmbedProps = {
|
|
isEmbed?: boolean;
|
|
};
|
|
|
|
export default function withEmbedSsr(getServerSideProps: GetServerSideProps) {
|
|
return async (context: GetServerSidePropsContext): Promise<GetServerSidePropsResult<EmbedProps>> => {
|
|
const ssrResponse = await getServerSideProps(context);
|
|
const embed = context.query.embed;
|
|
const layout = context.query.layout;
|
|
|
|
if ("redirect" in ssrResponse) {
|
|
// Use a dummy URL https://base as the fallback base URL so that URL parsing works for relative URLs as well.
|
|
const destinationUrlObj = new URL(ssrResponse.redirect.destination, "https://base");
|
|
|
|
// Make sure that redirect happens to /embed page and pass on embed query param as is for preserving Cal JS API namespace
|
|
const newDestinationUrl =
|
|
destinationUrlObj.pathname +
|
|
"/embed?" +
|
|
destinationUrlObj.searchParams.toString() +
|
|
"&layout=" +
|
|
layout +
|
|
"&embed=" +
|
|
embed;
|
|
|
|
return {
|
|
...ssrResponse,
|
|
redirect: {
|
|
...ssrResponse.redirect,
|
|
destination: newDestinationUrl,
|
|
},
|
|
};
|
|
}
|
|
|
|
if (!("props" in ssrResponse)) {
|
|
return ssrResponse;
|
|
}
|
|
return {
|
|
...ssrResponse,
|
|
props: {
|
|
...ssrResponse.props,
|
|
isEmbed: true,
|
|
},
|
|
};
|
|
};
|
|
}
|