From 9ad45bb47787758b694a02770326392551335d0e Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Tue, 28 Jan 2025 16:34:52 +0000 Subject: [PATCH] chore: migrate /auth/setup (#18941) --- .../(use-page-wrapper)/auth/setup/page.tsx | 19 ++++++++++++++ apps/web/app/future/auth/setup/page.tsx | 13 ---------- apps/web/middleware.ts | 1 + apps/web/pages/auth/setup/index.tsx | 26 ------------------- .../server/lib/setup/getServerSideProps.tsx | 7 ++--- 5 files changed, 22 insertions(+), 44 deletions(-) create mode 100644 apps/web/app/(use-page-wrapper)/auth/setup/page.tsx delete mode 100644 apps/web/app/future/auth/setup/page.tsx delete mode 100644 apps/web/pages/auth/setup/index.tsx diff --git a/apps/web/app/(use-page-wrapper)/auth/setup/page.tsx b/apps/web/app/(use-page-wrapper)/auth/setup/page.tsx new file mode 100644 index 0000000000..3115454d77 --- /dev/null +++ b/apps/web/app/(use-page-wrapper)/auth/setup/page.tsx @@ -0,0 +1,19 @@ +import { withAppDirSsr } from "app/WithAppDirSsr"; +import type { PageProps as ServerPageProps } from "app/_types"; +import { cookies, headers } from "next/headers"; + +import { buildLegacyCtx } from "@lib/buildLegacyCtx"; + +import { getServerSideProps } from "@server/lib/setup/getServerSideProps"; + +import Setup from "~/auth/setup-view"; +import type { PageProps as ClientPageProps } from "~/auth/setup-view"; + +const getData = withAppDirSsr(getServerSideProps); + +const ServerPage = async ({ params, searchParams }: ServerPageProps) => { + const props = await getData(buildLegacyCtx(headers(), cookies(), params, searchParams)); + return ; +}; + +export default ServerPage; diff --git a/apps/web/app/future/auth/setup/page.tsx b/apps/web/app/future/auth/setup/page.tsx deleted file mode 100644 index 5f4d478e45..0000000000 --- a/apps/web/app/future/auth/setup/page.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { withAppDirSsr } from "app/WithAppDirSsr"; -import { WithLayout } from "app/layoutHOC"; - -import { getServerSideProps } from "@server/lib/setup/getServerSideProps"; - -import Setup from "~/auth/setup-view"; -import type { PageProps } from "~/auth/setup-view"; - -export default WithLayout({ - getLayout: null, - Page: Setup, - getData: withAppDirSsr(getServerSideProps), -})<"P">; diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index c31bcfd3d1..e67f094844 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -163,6 +163,7 @@ export const config = { "/auth/verify-email-change", "/auth/verify-email", "/auth/verify", + "/auth/setup", /** * Paths required by routingForms.handle */ diff --git a/apps/web/pages/auth/setup/index.tsx b/apps/web/pages/auth/setup/index.tsx deleted file mode 100644 index 8f0a0e42fc..0000000000 --- a/apps/web/pages/auth/setup/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -"use client"; - -import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { Meta } from "@calcom/ui"; - -import PageWrapper from "@components/PageWrapper"; - -import { getServerSideProps } from "@server/lib/setup/getServerSideProps"; - -import type { PageProps } from "~/auth/setup-view"; -import Setup from "~/auth/setup-view"; - -const Page = (props: PageProps) => { - const { t } = useLocale(); - return ( - <> - - - - ); -}; - -Page.PageWrapper = PageWrapper; -export default Page; - -export { getServerSideProps }; diff --git a/apps/web/server/lib/setup/getServerSideProps.tsx b/apps/web/server/lib/setup/getServerSideProps.tsx index dbc0ccb6cc..b13b91205c 100644 --- a/apps/web/server/lib/setup/getServerSideProps.tsx +++ b/apps/web/server/lib/setup/getServerSideProps.tsx @@ -17,11 +17,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { if (session?.user.role && session?.user.role !== UserPermissionRole.ADMIN) { return { - redirect: { - destination: `/404`, - permanent: false, - }, - }; + notFound: true, + } as const; } const deploymentKey = await prisma.deployment.findUnique({