perf: remove WithLayout HOC from private booking page and booking embed (#19189)

This commit is contained in:
Benny Joo
2025-02-12 11:15:08 +01:00
committed by GitHub
parent 7969789d60
commit 207804bd97
6 changed files with 32 additions and 16 deletions
@@ -0,0 +1,21 @@
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps as ServerPageProps } from "app/_types";
import { cookies, headers } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import OldPage from "~/bookings/views/bookings-single-view";
import {
getServerSideProps,
type PageProps as ClientPageProps,
} from "~/bookings/views/bookings-single-view.getServerSideProps";
const getEmbedData = withEmbedSsrAppDir<ClientPageProps>(getServerSideProps);
const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
const props = await getEmbedData(context);
return <OldPage {...props} />;
};
export default ServerPage;
@@ -1,7 +1,6 @@
import { withAppDirSsr } from "app/WithAppDirSsr";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { cookies, headers } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
@@ -27,4 +26,11 @@ export const generateMetadata = async ({ params, searchParams }: _PageProps) =>
};
const getData = withAppDirSsr<PageProps>(getServerSideProps);
export default WithLayout({ getLayout: null, Page: Type, getData })<"P">;
const ServerPage = async ({ params, searchParams }: _PageProps) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
const pageProps = await getData(legacyCtx);
return <Type {...pageProps} />;
};
export default ServerPage;
@@ -1,9 +0,0 @@
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import { WithLayout } from "app/layoutHOC";
import OldPage from "~/bookings/views/bookings-single-view";
import { getServerSideProps, type PageProps } from "~/bookings/views/bookings-single-view.getServerSideProps";
const getEmbedData = withEmbedSsrAppDir<PageProps>(getServerSideProps);
export default WithLayout({ getLayout: null, getData: getEmbedData, Page: OldPage });
+3 -1
View File
@@ -4,7 +4,9 @@ import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
export default function useIsBookingPage(): boolean {
const pathname = usePathname();
const isBookingPage = ["/booking/", "/cancel", "/reschedule"].some((route) => pathname?.startsWith(route));
const isBookingPage = ["/booking", "/cancel", "/reschedule", "/d"].some((route) =>
pathname?.startsWith(route)
);
const searchParams = useCompatSearchParams();
const userParam = Boolean(searchParams?.get("user"));
@@ -1133,8 +1133,6 @@ const DisplayLocation = ({
<p className={className}>{locationToDisplay}</p>
);
Success.isBookingPage = true;
type RecurringBookingsProps = {
eventType: PageProps["eventType"];
recurringBookings: PageProps["recurringBookings"];
@@ -33,5 +33,3 @@ export default function Type({
</main>
);
}
Type.isBookingPage = true;