Scheduling infrastructure for absolutely everyone.
chore: cleanup - Remove WithLayout HoC itself (#19490)
Benny Jooa47cd5b10684
diff --git a/apps/web/app/WithAppDirSsg.tsx b/apps/web/app/WithAppDirSsg.tsxdeleted file mode 100644index ead0adf9700..00000000000--- a/apps/web/app/WithAppDirSsg.tsx+++ /dev/null@@ -1,31 +0,0 @@-import type { GetStaticProps, GetStaticPropsContext } from "next";-import { unstable_cache } from "next/cache";-import { notFound, redirect } from "next/navigation";--export const withAppDirSsg =- <T extends Record<string, any>>(getStaticProps: GetStaticProps<T>, routePath: string) =>- async (context: GetStaticPropsContext) => {- const cacheKey = JSON.stringify({- route: routePath,- params: context.params || {},- });-- const getCachedProps = unstable_cache(async () => {- const ssgResponse = await getStaticProps(context);-- if ("redirect" in ssgResponse) {- redirect(ssgResponse.redirect.destination);- }-- if ("notFound" in ssgResponse) {- notFound();- }-- return {- ...ssgResponse.props,- ...("trpcState" in ssgResponse.props && { dehydratedState: ssgResponse.props.trpcState }),- };- }, [`ssg-${cacheKey}`]);-- return getCachedProps();- };diff --git a/apps/web/app/future/[user]/[type]/embed/page.tsx b/apps/web/app/future/[user]/[type]/embed/page.tsxdeleted file mode 100644index 78fe30896dc..00000000000--- a/apps/web/app/future/[user]/[type]/embed/page.tsx+++ /dev/null@@ -1,10 +0,0 @@-import withEmbedSsrAppDir from "app/WithEmbedSSR";-import { WithLayout } from "app/layoutHOC";--import { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps";--import LegacyPage, { type PageProps } from "~/users/views/users-type-public-view";--const getEmbedData = withEmbedSsrAppDir<PageProps>(getServerSideProps);--export default WithLayout({ getLayout: null, getData: getEmbedData, Page: LegacyPage })<"P">;diff --git a/apps/web/app/future/[user]/embed/page.tsx b/apps/web/app/future/[user]/embed/page.tsxdeleted file mode 100644index 09070a22f9d..00000000000--- a/apps/web/app/future/[user]/embed/page.tsx+++ /dev/null@@ -1,11 +0,0 @@-import withEmbedSsrAppDir from "app/WithEmbedSSR";-import { WithLayout } from "app/layoutHOC";--import { getServerSideProps } from "@server/lib/[user]/getServerSideProps";--import type { PageProps as UserPageProps } from "~/users/views/users-public-view";-import LegacyPage from "~/users/views/users-public-view";--const getEmbedData = withEmbedSsrAppDir<UserPageProps>(getServerSideProps);--export default WithLayout({ getLayout: null, getData: getEmbedData, Page: LegacyPage })<"P">;diff --git a/apps/web/app/future/org/[orgSlug]/[user]/[type]/embed/page.tsx b/apps/web/app/future/org/[orgSlug]/[user]/[type]/embed/page.tsxdeleted file mode 100644index 081d18a07f9..00000000000--- a/apps/web/app/future/org/[orgSlug]/[user]/[type]/embed/page.tsx+++ /dev/null@@ -1,10 +0,0 @@-import Page from "@pages/org/[orgSlug]/[user]/[type]/embed";-import withEmbedSsrAppDir from "app/WithEmbedSSR";-import { WithLayout } from "app/layoutHOC";-import type { OrgTypePageProps } from "app/(booking-page-wrapper)/org/[orgSlug]/[user]/[type]/page";--import { getServerSideProps } from "@lib/org/[orgSlug]/[user]/[type]/getServerSideProps";--const getEmbedData = withEmbedSsrAppDir<OrgTypePageProps>(getServerSideProps);--export default WithLayout({ getLayout: null, getData: getEmbedData, isBookingPage: true, Page });diff --git a/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsx b/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsxdeleted file mode 100644index 4f214d72b38..00000000000--- a/apps/web/app/future/org/[orgSlug]/[user]/embed/page.tsx+++ /dev/null@@ -1,21 +0,0 @@-import withEmbedSsrAppDir from "app/WithEmbedSSR";-import { WithLayout } from "app/layoutHOC";-import type { OrgPageProps } from "app/(booking-page-wrapper)/org/[orgSlug]/[user]/page";--import { getServerSideProps } from "@lib/org/[orgSlug]/[user]/getServerSideProps";--import type { PageProps as TeamPageProps } from "~/team/team-view";-import TeamPage from "~/team/team-view";-import UserPage from "~/users/views/users-public-view";-import type { PageProps as UserPageProps } from "~/users/views/users-public-view";--const getEmbedData = withEmbedSsrAppDir<OrgPageProps>(getServerSideProps);--const Page = async (props: OrgPageProps) => {- if ((props as TeamPageProps)?.team) {- return <TeamPage {...(props as TeamPageProps)} />;- }- return <UserPage {...(props as UserPageProps)} />;-};--export default WithLayout({ getLayout: null, getData: getEmbedData, isBookingPage: true, ServerPage: Page });diff --git a/apps/web/app/future/org/[orgSlug]/embed/page.tsx b/apps/web/app/future/org/[orgSlug]/embed/page.tsxdeleted file mode 100644index 3a592b9af76..00000000000--- a/apps/web/app/future/org/[orgSlug]/embed/page.tsx+++ /dev/null@@ -1,16 +0,0 @@-import withEmbedSsrAppDir from "app/WithEmbedSSR";-import { WithLayout } from "app/layoutHOC";--import { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";--import type { PageProps } from "~/team/team-view";-import TeamPage from "~/team/team-view";--const getEmbedData = withEmbedSsrAppDir<PageProps>(getServerSideProps);--export default WithLayout({- Page: TeamPage,- getData: getEmbedData,- getLayout: null,- isBookingPage: true,-})<"P">;diff --git a/apps/web/app/layoutHOC.tsx b/apps/web/app/layoutHOC.tsxdeleted file mode 100644index 6e580e3dea0..00000000000--- a/apps/web/app/layoutHOC.tsx+++ /dev/null@@ -1,61 +0,0 @@-import type { LayoutProps, PageProps } from "app/_types";-import { type GetServerSidePropsContext } from "next";-import { cookies, headers } from "next/headers";--import { buildLegacyCtx } from "@lib/buildLegacyCtx";--import PageWrapper from "@components/PageWrapperAppDir";--type WithLayoutParams<T extends Record<string, any>> = {- getLayout?: ((page: React.ReactElement) => React.ReactNode) | null;- getServerLayout?: (page: React.ReactElement) => Promise<React.ReactNode | null>;- Page?: (props: T) => React.ReactElement | null;- ServerPage?: (props: T) => Promise<React.ReactElement> | null;- getData?: (arg: GetServerSidePropsContext) => Promise<T | undefined>;- isBookingPage?: boolean;- requiresLicense?: boolean;-};--export function WithLayout<T extends Record<string, any>>({- getLayout,- getServerLayout,- getData,- ServerPage,- Page,- isBookingPage,- requiresLicense,-}: WithLayoutParams<T>) {- // eslint-disable-next-line react/display-name- return async <P extends "P" | "L">(p: P extends "P" ? PageProps : LayoutProps) => {- const h = headers();- const nonce = h.get("x-nonce") ?? undefined;- let props = {} as T;-- if ("searchParams" in p && getData) {- props = (await getData(buildLegacyCtx(h, cookies(), p.params, p.searchParams))) ?? ({} as T);- }-- // `p.children` exists only for layout.tsx files- const childrenFromLayoutFile = "children" in p ? p.children : null;- const page = ServerPage ? (- await ServerPage({ ...props, ...p })- ) : Page ? (- <Page {...props} />- ) : (- childrenFromLayoutFile- );- const pageWithServerLayout = page ? (getServerLayout ? await getServerLayout(page) : page) : null;-- return (- <PageWrapper- getLayout={getLayout}- requiresLicense={requiresLicense || !!(Page && "requiresLicense" in Page && Page.requiresLicense)}- nonce={nonce}- themeBasis={null}- isBookingPage={isBookingPage || !!(Page && "isBookingPage" in Page && Page.isBookingPage)}- {...props}>- {pageWithServerLayout}- </PageWrapper>- );- };-}diff --git a/apps/web/pagesAndRewritePaths.js b/apps/web/pagesAndRewritePaths.jsindex f64a0d33df5..4fb57e7084c 100644--- a/apps/web/pagesAndRewritePaths.js+++ b/apps/web/pagesAndRewritePaths.js@@ -18,13 +18,11 @@ let pages = (exports.pages = glob.replace(/(\.tsx|\.js|\.ts)/, "").replace(/\/.*/, ""))- // "/future" is a temporary directory for incremental migration to App Router.filter((v, i, self) =>self.indexOf(v) === i &&!["[user]",- "future","_trpc","layout","layoutHOC",diff --git a/packages/embeds/embed-core/playground.ts b/packages/embeds/embed-core/playground.tsindex f1f71d85848..bfdb565c1cd 100644--- a/packages/embeds/embed-core/playground.ts+++ b/packages/embeds/embed-core/playground.ts@@ -31,9 +31,6 @@ const only = searchParams.get("only");const colorScheme = searchParams.get("color-scheme");const prerender = searchParams.get("prerender");-// @ts-expect-error We haven't defined ENABLE_FUTURE_ROUTES as it is a playground specific variable.-window.ENABLE_FUTURE_ROUTES = searchParams.get("future-routes") === "true";-if (colorScheme) {document.documentElement.style.colorScheme = colorScheme;}diff --git a/packages/embeds/embed-core/src/embed.ts b/packages/embeds/embed-core/src/embed.tsindex 7375fb4c187..2d67a37b1e4 100644--- a/packages/embeds/embed-core/src/embed.ts+++ b/packages/embeds/embed-core/src/embed.ts@@ -297,12 +297,6 @@ export class Cal {urlInstance.pathname = `${urlInstance.pathname}/embed`;}- // eslint-disable-next-line @typescript-eslint/ban-ts-comment- // @ts-ignore- if (window.ENABLE_FUTURE_ROUTES) {- urlInstance.pathname = `/future${urlInstance.pathname}`;- }-urlInstance.searchParams.set("embed", this.namespace);if (embedConfig.debug) {