chore: technical debt clearing - remove getServerSideProps for /event-types (#18733)

* chore: technical debt clearing - remove getServerSideProps for event-types

* refactor
This commit is contained in:
Benny Joo
2025-01-17 21:35:03 +01:00
committed by GitHub
parent 6be69b820c
commit 245196fbf3
3 changed files with 20 additions and 26 deletions
+20 -4
View File
@@ -1,8 +1,14 @@
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 { redirect } from "next/navigation";
import { getServerSideProps } from "@lib/event-types/getServerSideProps";
import { getServerSessionForAppDir } from "@calcom/features/auth/lib/get-server-session-for-app-dir";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import { ssrInit } from "@server/lib/ssr";
import EventTypes from "~/event-types/views/event-types-listing-view";
@@ -12,6 +18,16 @@ export const generateMetadata = async () =>
(t) => t("event_types_page_subtitle")
);
const getData = withAppDirSsr(getServerSideProps);
const Page = async ({ params, searchParams }: PageProps) => {
const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
const session = await getServerSessionForAppDir();
if (!session?.user?.id) {
redirect("/auth/login");
}
export default WithLayout({ getLayout: null, getData, Page: EventTypes })<"P">;
await ssrInit(context);
return <EventTypes />;
};
export default WithLayout({ ServerPage: Page })<"P">;
@@ -1,21 +0,0 @@
import type { GetServerSidePropsContext } from "next";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { ssrInit } from "@server/lib/ssr";
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);
const session = await getServerSession({ req: context.req });
if (!session) {
return {
redirect: {
permanent: false,
destination: "/auth/login",
},
};
}
return { props: { trpcState: ssr.dehydrate() } };
};
@@ -944,7 +944,6 @@ const InfiniteScrollMain = ({
const EventTypesPage: React.FC = () => {
const { t } = useLocale();
const searchParams = useSearchParams();
const { data: user } = useMeQuery();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_showProfileBanner, setShowProfileBanner] = useState(false);