refactor: check insights feature flag in higher stack (#21341)

This commit is contained in:
Benny Joo authored and GitHub committed 2025-05-15 12:41:22 -07:00
1 parent 29b8d68f45
commit 0802ebb17b
4 files changed
+10 -30

No files matched your search

@@ -1,12 +1,22 @@
import { getTranslate } from "app/_utils"; import { getTranslate } from "app/_utils";
import { notFound } from "next/navigation";
import { CTA_CONTAINER_CLASS_NAME } from "@calcom/features/data-table/lib/utils"; import { CTA_CONTAINER_CLASS_NAME } from "@calcom/features/data-table/lib/utils";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import Shell from "@calcom/features/shell/Shell"; import Shell from "@calcom/features/shell/Shell";
import UpgradeTipWrapper from "./UpgradeTipWrapper"; import UpgradeTipWrapper from "./UpgradeTipWrapper";
export default async function InsightsLayout({ children }: { children: React.ReactNode }) { export default async function InsightsLayout({ children }: { children: React.ReactNode }) {
const featuresRepository = new FeaturesRepository();
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
if (!insightsEnabled) {
return notFound();
}
const t = await getTranslate(); const t = await getTranslate();
return ( return (
<> <>
<div> <div>
@@ -1,7 +1,4 @@
import { _generateMetadata } from "app/_utils"; import { _generateMetadata } from "app/_utils";
import { notFound } from "next/navigation";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import InsightsPage from "~/insights/insights-view"; import InsightsPage from "~/insights/insights-view";
@@ -15,12 +12,5 @@ export const generateMetadata = async () =>
); );
export default async function Page() { export default async function Page() {
const featuresRepository = new FeaturesRepository();
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
if (!insightsEnabled) {
return notFound();
}
return <InsightsPage />; return <InsightsPage />;
} }
@@ -1,7 +1,4 @@
import { _generateMetadata } from "app/_utils"; import { _generateMetadata } from "app/_utils";
import { notFound } from "next/navigation";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import InsightsVirtualQueuesPage from "~/insights/insights-virtual-queues-view"; import InsightsVirtualQueuesPage from "~/insights/insights-virtual-queues-view";
@@ -15,12 +12,5 @@ export const generateMetadata = async () =>
); );
export default async function Page() { export default async function Page() {
const featuresRepository = new FeaturesRepository();
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
if (!insightsEnabled) {
return notFound();
}
return <InsightsVirtualQueuesPage />; return <InsightsVirtualQueuesPage />;
} }
@@ -1,7 +1,4 @@
import { _generateMetadata } from "app/_utils"; import { _generateMetadata } from "app/_utils";
import { notFound } from "next/navigation";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import InsightsRoutingPage from "~/insights/insights-routing-view"; import InsightsRoutingPage from "~/insights/insights-routing-view";
@@ -15,12 +12,5 @@ export const generateMetadata = async () =>
); );
export default async function Page() { export default async function Page() {
const featuresRepository = new FeaturesRepository();
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
if (!insightsEnabled) {
return notFound();
}
return <InsightsRoutingPage />; return <InsightsRoutingPage />;
} }