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 6cdb42ab56..be9c0eb3c8 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 898959c4ef..d42fdace8d 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 0000000000..aac25c869b --- /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(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 ; +}; +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 0f44e09f32..f110db9557 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(getServerSideProps); +const getData = withAppDirSsr(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 ; +}; +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 0749c15a92..a3196f3b67 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 ; }; -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 17a4f29266..008602773b 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(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 ; +}; +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 18354c4f9c..0000000000 --- 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(getServerSideProps), -})<"P">; diff --git a/apps/web/server/lib/auth/signin/getServerSideProps.tsx b/apps/web/server/lib/auth/signin/getServerSideProps.tsx index 9c6da32de4..34784d0e46 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,