diff --git a/apps/web/app/insights/layout.tsx b/apps/web/app/insights/layout.tsx new file mode 100644 index 0000000000..ad256d0356 --- /dev/null +++ b/apps/web/app/insights/layout.tsx @@ -0,0 +1,5 @@ +import { WithLayout } from "app/layoutHOC"; + +import { getInsightsLayout } from "~/insights/layout"; + +export default WithLayout({ getLayout: getInsightsLayout }); diff --git a/apps/web/app/insights/page.tsx b/apps/web/app/insights/page.tsx index a2f3bdeec8..ccdaa1b1d5 100644 --- a/apps/web/app/insights/page.tsx +++ b/apps/web/app/insights/page.tsx @@ -1,10 +1,8 @@ -import { withAppDirSsr } from "app/WithAppDirSsr"; import { _generateMetadata } from "app/_utils"; -import { WithLayout } from "app/layoutHOC"; +import { notFound } from "next/navigation"; -import { getServerSideProps } from "@lib/insights/getServerSideProps"; +import { getFeatureFlag } from "@calcom/features/flags/server/utils"; -import type { PageProps } from "~/insights/insights-view"; import InsightsPage from "~/insights/insights-view"; export const generateMetadata = async () => @@ -13,6 +11,13 @@ export const generateMetadata = async () => (t) => t("insights_subtitle") ); -const getData = withAppDirSsr(getServerSideProps); +export default async function Page() { + const prisma = await import("@calcom/prisma").then((mod) => mod.default); + const insightsEnabled = await getFeatureFlag(prisma, "insights"); -export default WithLayout({ getLayout: null, getData, Page: InsightsPage }); + if (!insightsEnabled) { + return notFound(); + } + + return ; +} diff --git a/apps/web/app/insights/routing/page.tsx b/apps/web/app/insights/routing/page.tsx index f6a01045f1..39a30efbf3 100644 --- a/apps/web/app/insights/routing/page.tsx +++ b/apps/web/app/insights/routing/page.tsx @@ -1,8 +1,7 @@ -import { withAppDirSsr } from "app/WithAppDirSsr"; import { _generateMetadata } from "app/_utils"; -import { WithLayout } from "app/layoutHOC"; +import { notFound } from "next/navigation"; -import { getServerSideProps } from "@lib/insights/getServerSideProps"; +import { getFeatureFlag } from "@calcom/features/flags/server/utils"; import InsightsRoutingPage from "~/insights/insights-routing-view"; @@ -12,6 +11,13 @@ export const generateMetadata = async () => (t) => t("insights_subtitle") ); -const getData = withAppDirSsr(getServerSideProps); +export default async function Page() { + const prisma = await import("@calcom/prisma").then((mod) => mod.default); + const insightsEnabled = await getFeatureFlag(prisma, "insights"); -export default WithLayout({ getLayout: null, getData, Page: InsightsRoutingPage }); + if (!insightsEnabled) { + return notFound(); + } + + return ; +} diff --git a/apps/web/app/insights/virtual-queues/page.tsx b/apps/web/app/insights/virtual-queues/page.tsx index 073f205f09..81e8fe6d8e 100644 --- a/apps/web/app/insights/virtual-queues/page.tsx +++ b/apps/web/app/insights/virtual-queues/page.tsx @@ -1,8 +1,7 @@ -import { withAppDirSsr } from "app/WithAppDirSsr"; import { _generateMetadata } from "app/_utils"; -import { WithLayout } from "app/layoutHOC"; +import { notFound } from "next/navigation"; -import { getServerSideProps } from "@lib/insights/getServerSideProps"; +import { getFeatureFlag } from "@calcom/features/flags/server/utils"; import InsightsVirtualQueuesPage from "~/insights/insights-virtual-queues-view"; @@ -12,6 +11,13 @@ export const generateMetadata = async () => (t) => t("insights_subtitle") ); -const getData = withAppDirSsr(getServerSideProps); +export default async function Page() { + const prisma = await import("@calcom/prisma").then((mod) => mod.default); + const insightsEnabled = await getFeatureFlag(prisma, "insights"); -export default WithLayout({ getLayout: null, getData, Page: InsightsVirtualQueuesPage }); + if (!insightsEnabled) { + return notFound(); + } + + return ; +} diff --git a/apps/web/lib/insights/getServerSideProps.tsx b/apps/web/lib/insights/getServerSideProps.tsx deleted file mode 100644 index a6108e44ac..0000000000 --- a/apps/web/lib/insights/getServerSideProps.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { getFeatureFlag } from "@calcom/features/flags/server/utils"; - -// If feature flag is disabled, return not found on getServerSideProps -export const getServerSideProps = async () => { - const prisma = await import("@calcom/prisma").then((mod) => mod.default); - const insightsEnabled = await getFeatureFlag(prisma, "insights"); - - if (!insightsEnabled) { - return { - notFound: true, - } as const; - } - - return { props: {} }; -}; diff --git a/apps/web/modules/insights/insights-routing-view.tsx b/apps/web/modules/insights/insights-routing-view.tsx index 95d826f36d..37e3d79d53 100644 --- a/apps/web/modules/insights/insights-routing-view.tsx +++ b/apps/web/modules/insights/insights-routing-view.tsx @@ -1,35 +1,35 @@ "use client"; -import { FailedBookingsByField, RoutingFormResponsesTable, RoutedToPerPeriod } from "@calcom/features/insights/components"; +import { + FailedBookingsByField, + RoutingFormResponsesTable, + RoutedToPerPeriod, +} from "@calcom/features/insights/components"; import { FiltersProvider } from "@calcom/features/insights/context/FiltersProvider"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import InsightsLayout from "./layout"; - export default function InsightsRoutingFormResponsesPage() { const { t } = useLocale(); return ( - - -
- + +
+ - + - + - - {t("looking_for_more_insights")}{" "} - - {" "} - {t("contact_support")} - - -
-
- + + {t("looking_for_more_insights")}{" "} + + {" "} + {t("contact_support")} + + +
+
); } diff --git a/apps/web/modules/insights/insights-view.tsx b/apps/web/modules/insights/insights-view.tsx index 4a51126350..b481850347 100644 --- a/apps/web/modules/insights/insights-view.tsx +++ b/apps/web/modules/insights/insights-view.tsx @@ -16,52 +16,43 @@ import { FiltersProvider } from "@calcom/features/insights/context/FiltersProvid import { Filters } from "@calcom/features/insights/filters"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import type { getServerSideProps } from "@lib/insights/getServerSideProps"; -import type { inferSSRProps } from "@lib/types/inferSSRProps"; - -import InsightsLayout from "./layout"; - -export type PageProps = inferSSRProps; - export default function InsightsPage() { const { t } = useLocale(); return ( - - - + + -
- +
+ - + -
- +
+ - -
-
- - -
- -
- - - -
- - {t("looking_for_more_insights")}{" "} - - {" "} - {t("contact_support")} - - +
- - +
+ + +
+ +
+ + + +
+ + {t("looking_for_more_insights")}{" "} + + {" "} + {t("contact_support")} + + +
+ ); } diff --git a/apps/web/modules/insights/insights-virtual-queues-view.tsx b/apps/web/modules/insights/insights-virtual-queues-view.tsx index 845229ff63..a07b198406 100644 --- a/apps/web/modules/insights/insights-virtual-queues-view.tsx +++ b/apps/web/modules/insights/insights-virtual-queues-view.tsx @@ -8,8 +8,6 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc"; import { Label, Select } from "@calcom/ui"; -import InsightsLayout from "./layout"; - export default function InsightsVirtualQueuesPage() { const { t } = useLocale(); const { data: routingForms, isLoading: isRoutingFormsLoading } = @@ -24,7 +22,7 @@ export default function InsightsVirtualQueuesPage() { } return ( - + <>