Skip to content

Commit 87c89a9

Browse files
authored
perf: check feature flag in layout level for /settings/organizations/new routes (calcom#23057)
* remove getServerSideProps * add layout * update pages
1 parent e237749 commit 87c89a9

7 files changed

Lines changed: 13 additions & 77 deletions

File tree

apps/web/app/(use-page-wrapper)/settings/organizations/new/about/page.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import { withAppDirSsr } from "app/WithAppDirSsr";
2-
import type { PageProps } from "app/_types";
31
import { _generateMetadata } from "app/_utils";
4-
import { cookies, headers } from "next/headers";
5-
6-
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
7-
import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps";
82

93
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/about-view";
104

@@ -17,10 +11,7 @@ export const generateMetadata = async () =>
1711
"/settings/organizations/new/about"
1812
);
1913

20-
const getData = withAppDirSsr(getServerSideProps);
21-
22-
const ServerPage = async ({ params, searchParams }: PageProps) => {
23-
await getData(buildLegacyCtx(await headers(), await cookies(), await params, await searchParams));
14+
const ServerPage = async () => {
2415
return (
2516
<LayoutWrapper>
2617
<LegacyPage />

apps/web/app/(use-page-wrapper)/settings/organizations/new/add-teams/page.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import { withAppDirSsr } from "app/WithAppDirSsr";
2-
import type { PageProps } from "app/_types";
31
import { _generateMetadata } from "app/_utils";
4-
import { cookies, headers } from "next/headers";
5-
6-
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
7-
import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps";
82

93
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/add-teams-view";
104

@@ -17,10 +11,7 @@ export const generateMetadata = async () =>
1711
"/settings/organizations/new/add-teams"
1812
);
1913

20-
const getData = withAppDirSsr(getServerSideProps);
21-
22-
const ServerPage = async ({ params, searchParams }: PageProps) => {
23-
await getData(buildLegacyCtx(await headers(), await cookies(), await params, await searchParams));
14+
const ServerPage = async () => {
2415
return (
2516
<LayoutWrapper>
2617
<LegacyPage />

apps/web/app/(use-page-wrapper)/settings/organizations/new/handover/page.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import { withAppDirSsr } from "app/WithAppDirSsr";
2-
import type { PageProps } from "app/_types";
31
import { _generateMetadata } from "app/_utils";
4-
import { cookies } from "next/headers";
5-
import { headers } from "next/headers";
6-
7-
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
8-
import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps";
92

103
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/onboarding-handover";
114

@@ -18,10 +11,7 @@ export const generateMetadata = async () =>
1811
"/settings/organizations/new/handover"
1912
);
2013

21-
const getData = withAppDirSsr(getServerSideProps);
22-
23-
const ServerPage = async ({ params, searchParams }: PageProps) => {
24-
await getData(buildLegacyCtx(await headers(), await cookies(), await params, await searchParams));
14+
const ServerPage = async () => {
2515
return (
2616
<LayoutWrapper>
2717
<LegacyPage />

apps/web/lib/settings/organizations/new/getServerSideProps.tsx renamed to apps/web/app/(use-page-wrapper)/settings/organizations/new/layout.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
import type { GetServerSidePropsResult } from "next";
1+
import { _generateMetadata } from "app/_utils";
2+
import { notFound } from "next/navigation";
23

34
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
45
import { prisma } from "@calcom/prisma";
56

6-
export const getServerSideProps = async (): Promise<GetServerSidePropsResult<{ isOrg: boolean }>> => {
7+
export default async function Layout({ children }: { children: React.ReactNode }) {
78
const featuresRepository = new FeaturesRepository(prisma);
89
const organizations = await featuresRepository.checkIfFeatureIsEnabledGlobally("organizations");
9-
// Check if organizations are enabled
10+
1011
if (!organizations) {
11-
return {
12-
notFound: true,
13-
};
12+
return notFound();
1413
}
1514

16-
return {
17-
props: {
18-
isOrg: true,
19-
},
20-
};
21-
};
15+
return children;
16+
}

apps/web/app/(use-page-wrapper)/settings/organizations/new/onboard-members/page.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import { withAppDirSsr } from "app/WithAppDirSsr";
2-
import type { PageProps } from "app/_types";
31
import { _generateMetadata } from "app/_utils";
4-
import { cookies, headers } from "next/headers";
5-
6-
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
7-
import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps";
82

93
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/onboard-members-view";
104

@@ -17,10 +11,7 @@ export const generateMetadata = async () =>
1711
"/settings/organizations/new/onboard-members"
1812
);
1913

20-
const getData = withAppDirSsr(getServerSideProps);
21-
22-
const ServerPage = async ({ params, searchParams }: PageProps) => {
23-
await getData(buildLegacyCtx(await headers(), await cookies(), await params, await searchParams));
14+
const ServerPage = async () => {
2415
return (
2516
<LayoutWrapper>
2617
<LegacyPage />

apps/web/app/(use-page-wrapper)/settings/organizations/new/page.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import { withAppDirSsr } from "app/WithAppDirSsr";
2-
import type { PageProps } from "app/_types";
31
import { _generateMetadata } from "app/_utils";
4-
import { cookies, headers } from "next/headers";
52

63
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
74

8-
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
9-
import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps";
10-
115
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/create-new-view";
126

137
export const generateMetadata = async () =>
@@ -19,14 +13,7 @@ export const generateMetadata = async () =>
1913
"/settings/organizations/new"
2014
);
2115

22-
type Props = {
23-
isOrg: boolean;
24-
};
25-
26-
const getData = withAppDirSsr<Props>(getServerSideProps);
27-
28-
const ServerPage = async ({ params, searchParams }: PageProps) => {
29-
await getData(buildLegacyCtx(await headers(), await cookies(), await params, await searchParams));
16+
const ServerPage = async () => {
3017
return (
3118
<LayoutWrapper>
3219
<LicenseRequired>

apps/web/app/(use-page-wrapper)/settings/organizations/new/status/page.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import { withAppDirSsr } from "app/WithAppDirSsr";
2-
import type { PageProps } from "app/_types";
31
import { _generateMetadata } from "app/_utils";
4-
import { cookies, headers } from "next/headers";
5-
6-
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
7-
import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps";
82

93
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/payment-status-view";
104

@@ -17,10 +11,7 @@ export const generateMetadata = async () =>
1711
"/settings/organizations/new/status"
1812
);
1913

20-
const getData = withAppDirSsr(getServerSideProps);
21-
22-
const ServerPage = async ({ params, searchParams }: PageProps) => {
23-
await getData(buildLegacyCtx(await headers(), await cookies(), await params, await searchParams));
14+
const ServerPage = async () => {
2415
return (
2516
<LayoutWrapper>
2617
<LegacyPage />

0 commit comments

Comments
 (0)