From 207804bd970ce155fa634e499203c80c9a834397 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Wed, 12 Feb 2025 10:15:08 +0000 Subject: [PATCH] perf: remove WithLayout HOC from private booking page and booking embed (#19189) --- .../booking/[uid]/embed/page.tsx | 21 +++++++++++++++++++ .../d/[link]/[slug]/page.tsx | 10 +++++++-- apps/web/app/booking/[uid]/embed/page.tsx | 9 -------- apps/web/lib/hooks/useIsBookingPage.ts | 4 +++- .../bookings/views/bookings-single-view.tsx | 2 -- apps/web/modules/d/[link]/d-type-view.tsx | 2 -- 6 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 apps/web/app/(use-page-wrapper)/booking/[uid]/embed/page.tsx rename apps/web/app/{ => (use-page-wrapper)}/d/[link]/[slug]/page.tsx (81%) delete mode 100644 apps/web/app/booking/[uid]/embed/page.tsx diff --git a/apps/web/app/(use-page-wrapper)/booking/[uid]/embed/page.tsx b/apps/web/app/(use-page-wrapper)/booking/[uid]/embed/page.tsx new file mode 100644 index 0000000000..d0e4c69b5a --- /dev/null +++ b/apps/web/app/(use-page-wrapper)/booking/[uid]/embed/page.tsx @@ -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(getServerSideProps); + +const ServerPage = async ({ params, searchParams }: ServerPageProps) => { + const context = buildLegacyCtx(headers(), cookies(), params, searchParams); + const props = await getEmbedData(context); + return ; +}; + +export default ServerPage; diff --git a/apps/web/app/d/[link]/[slug]/page.tsx b/apps/web/app/(use-page-wrapper)/d/[link]/[slug]/page.tsx similarity index 81% rename from apps/web/app/d/[link]/[slug]/page.tsx rename to apps/web/app/(use-page-wrapper)/d/[link]/[slug]/page.tsx index 2e3ffac4ba..68fc6cd3fd 100644 --- a/apps/web/app/d/[link]/[slug]/page.tsx +++ b/apps/web/app/(use-page-wrapper)/d/[link]/[slug]/page.tsx @@ -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(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 ; +}; + +export default ServerPage; diff --git a/apps/web/app/booking/[uid]/embed/page.tsx b/apps/web/app/booking/[uid]/embed/page.tsx deleted file mode 100644 index 28f96ba531..0000000000 --- a/apps/web/app/booking/[uid]/embed/page.tsx +++ /dev/null @@ -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(getServerSideProps); - -export default WithLayout({ getLayout: null, getData: getEmbedData, Page: OldPage }); diff --git a/apps/web/lib/hooks/useIsBookingPage.ts b/apps/web/lib/hooks/useIsBookingPage.ts index ffa6804e02..3245b5a2be 100644 --- a/apps/web/lib/hooks/useIsBookingPage.ts +++ b/apps/web/lib/hooks/useIsBookingPage.ts @@ -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")); diff --git a/apps/web/modules/bookings/views/bookings-single-view.tsx b/apps/web/modules/bookings/views/bookings-single-view.tsx index 407778fef6..a2664ca60b 100644 --- a/apps/web/modules/bookings/views/bookings-single-view.tsx +++ b/apps/web/modules/bookings/views/bookings-single-view.tsx @@ -1133,8 +1133,6 @@ const DisplayLocation = ({

{locationToDisplay}

); -Success.isBookingPage = true; - type RecurringBookingsProps = { eventType: PageProps["eventType"]; recurringBookings: PageProps["recurringBookings"]; diff --git a/apps/web/modules/d/[link]/d-type-view.tsx b/apps/web/modules/d/[link]/d-type-view.tsx index d4b781b162..d4bc2246ee 100644 --- a/apps/web/modules/d/[link]/d-type-view.tsx +++ b/apps/web/modules/d/[link]/d-type-view.tsx @@ -33,5 +33,3 @@ export default function Type({ ); } - -Type.isBookingPage = true;