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

This commit is contained in:
Benny Joo authored and GitHub committed 2025-01-31 19:48:58 +01:00
1 parent 7bbacca32a
commit 564cc3a394
8 files changed
+46 -42

No files matched your search

@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
-14
View File
@@ -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">;
@@ -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,