Skip to content

Scheduling infrastructure for absolutely everyone.

perf: remove WithLayout from more App Router routes (#19036)

Benny Joo564cc3a394db
diff --git a/apps/web/app/auth/oauth2/authorize/page.tsx b/apps/web/app/(use-page-wrapper)/auth/oauth2/authorize/page.tsx
similarity index 68%
rename from apps/web/app/auth/oauth2/authorize/page.tsx
rename to apps/web/app/(use-page-wrapper)/auth/oauth2/authorize/page.tsx
index 6cdb42ab56b..be9c0eb3c80 100644
--- a/apps/web/app/auth/oauth2/authorize/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/auth/oauth2/authorize/page.tsx
@@ -1,5 +1,4 @@
import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
import Page from "~/auth/oauth2/authorize-view";
@@ -10,7 +9,4 @@ export const generateMetadata = async () => {
);
};
-export default WithLayout({
- getLayout: null,
- Page,
-});
+export default Page;
diff --git a/apps/web/app/auth/platform/authorize/page.tsx b/apps/web/app/(use-page-wrapper)/auth/platform/authorize/page.tsx
similarity index 69%
rename from apps/web/app/auth/platform/authorize/page.tsx
rename to apps/web/app/(use-page-wrapper)/auth/platform/authorize/page.tsx
index 898959c4ef5..d42fdace8d0 100644
--- a/apps/web/app/auth/platform/authorize/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/auth/platform/authorize/page.tsx
@@ -1,5 +1,4 @@
import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
import Page from "~/auth/platform/authorize-view";
@@ -10,7 +9,4 @@ export const generateMetadata = async () => {
);
};
-export default WithLayout({
- getLayout: null,
- Page,
-});
+export default Page;
diff --git a/apps/web/app/(use-page-wrapper)/auth/signin/page.tsx b/apps/web/app/(use-page-wrapper)/auth/signin/page.tsx
new file mode 100644
index 00000000000..aac25c869bf
--- /dev/null
+++ b/apps/web/app/(use-page-wrapper)/auth/signin/page.tsx
@@ -0,0 +1,26 @@
+import { withAppDirSsr } from "app/WithAppDirSsr";
+import type { PageProps as ServerPageProps } from "app/_types";
+import { cookies, headers } from "next/headers";
+import { redirect } from "next/navigation";
+
+import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
+
+import { buildLegacyCtx } from "@lib/buildLegacyCtx";
+
+import { getServerSideProps } from "@server/lib/auth/signin/getServerSideProps";
+
+import SignIn from "~/auth/signin-view";
+import type { PageProps as ClientPageProps } from "~/auth/signin-view";
+
+const getData = withAppDirSsr<ClientPageProps>(getServerSideProps);
+const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
+ const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
+ const session = await getServerSession({ req: context.req });
+ if (session) {
+ redirect("/");
+ }
+
+ const props = await getData(context);
+ return <SignIn {...props} />;
+};
+export default ServerPage;
diff --git a/apps/web/app/booking/[uid]/page.tsx b/apps/web/app/(use-page-wrapper)/booking/[uid]/page.tsx
similarity index 71%
rename from apps/web/app/booking/[uid]/page.tsx
rename to apps/web/app/(use-page-wrapper)/booking/[uid]/page.tsx
index 0f44e09f320..f110db95579 100644
--- a/apps/web/app/booking/[uid]/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/booking/[uid]/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 { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
@@ -10,7 +9,10 @@ import { BookingStatus } from "@calcom/prisma/enums";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import OldPage from "~/bookings/views/bookings-single-view";
-import { getServerSideProps, type PageProps } from "~/bookings/views/bookings-single-view.getServerSideProps";
+import {
+ getServerSideProps,
+ type PageProps as ClientPageProps,
+} from "~/bookings/views/bookings-single-view.getServerSideProps";
export const generateMetadata = async ({ params, searchParams }: _PageProps) => {
const { bookingInfo, eventType, recurringBookings, orgSlug } = await getData(
@@ -28,6 +30,11 @@ export const generateMetadata = async ({ params, searchParams }: _PageProps) =>
);
};
-const getData = withAppDirSsr<PageProps>(getServerSideProps);
+const getData = withAppDirSsr<ClientPageProps>(getServerSideProps);
-export default WithLayout({ getLayout: null, getData, Page: OldPage });
+const ServerPage = async ({ params, searchParams }: _PageProps) => {
+ const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
+ const props = await getData(context);
+ return <OldPage {...props} />;
+};
+export default ServerPage;
diff --git a/apps/web/app/booking/dry-run-successful/page.tsx b/apps/web/app/(use-page-wrapper)/booking/dry-run-successful/page.tsx
similarity index 80%
rename from apps/web/app/booking/dry-run-successful/page.tsx
rename to apps/web/app/(use-page-wrapper)/booking/dry-run-successful/page.tsx
index 0749c15a924..a3196f3b678 100644
--- a/apps/web/app/booking/dry-run-successful/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/booking/dry-run-successful/page.tsx
@@ -1,5 +1,4 @@
import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
import BookingDryRunSuccessView from "~/bookings/views/booking-dry-run-success-view";
@@ -14,4 +13,4 @@ const Page = async () => {
return <BookingDryRunSuccessView />;
};
-export default WithLayout({ ServerPage: Page });
+export default Page;
diff --git a/apps/web/app/payment/[uid]/page.tsx b/apps/web/app/(use-page-wrapper)/payment/[uid]/page.tsx
similarity index 79%
rename from apps/web/app/payment/[uid]/page.tsx
rename to apps/web/app/(use-page-wrapper)/payment/[uid]/page.tsx
index 17a4f29266b..008602773b1 100644
--- a/apps/web/app/payment/[uid]/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/payment/[uid]/page.tsx
@@ -1,7 +1,6 @@
import { withAppDirSsr } from "app/WithAppDirSsr";
import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
import { cookies, headers } from "next/headers";
import PaymentPage from "@calcom/features/ee/payments/components/PaymentPage";
@@ -21,4 +20,9 @@ export const generateMetadata = async ({ params, searchParams }: PageProps) => {
const getData = withAppDirSsr<PaymentPageProps>(getServerSideProps);
-export default WithLayout({ getLayout: null, getData, Page: PaymentPage });
+const ServerPage = async ({ params, searchParams }: PageProps) => {
+ const props = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams));
+
+ return <PaymentPage {...props} />;
+};
+export default ServerPage;
diff --git a/apps/web/app/auth/signin/page.tsx b/apps/web/app/auth/signin/page.tsx
deleted file mode 100644
index 18354c4f9c7..00000000000
--- a/apps/web/app/auth/signin/page.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { withAppDirSsr } from "app/WithAppDirSsr";
-import { WithLayout } from "app/layoutHOC";
-
-import { getServerSideProps } from "@server/lib/auth/signin/getServerSideProps";
-
-import SignIn from "~/auth/signin-view";
-import type { PageProps } from "~/auth/signin-view";
-
-export default WithLayout({
- getLayout: null,
- Page: SignIn,
- // @ts-expect-error TODO: fix this
- getData: withAppDirSsr<PageProps>(getServerSideProps),
-})<"P">;
diff --git a/apps/web/server/lib/auth/signin/getServerSideProps.tsx b/apps/web/server/lib/auth/signin/getServerSideProps.tsx
index 9c6da32de47..34784d0e464 100644
--- a/apps/web/server/lib/auth/signin/getServerSideProps.tsx
+++ b/apps/web/server/lib/auth/signin/getServerSideProps.tsx
@@ -1,19 +1,9 @@
import type { GetServerSidePropsContext } from "next";
import { getProviders, getCsrfToken } from "next-auth/react";
-import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
-
export async function getServerSideProps(context: GetServerSidePropsContext) {
- const { req } = context;
-
- const session = await getServerSession({ req });
const csrfToken = await getCsrfToken(context);
const providers = await getProviders();
- if (session) {
- return {
- redirect: { destination: "/" },
- };
- }
return {
props: {
csrfToken,