Scheduling infrastructure for absolutely everyone.
perf: separate client vs server code from insights layout (#19285)
Benny Joo5c6f52f1d4c5
diff --git a/apps/web/app/(use-page-wrapper)/insights/UpgradeTipWrapper.tsx b/apps/web/app/(use-page-wrapper)/insights/UpgradeTipWrapper.tsxnew file mode 100644index 00000000000..7ad886fee1c--- /dev/null+++ b/apps/web/app/(use-page-wrapper)/insights/UpgradeTipWrapper.tsx@@ -0,0 +1,53 @@+"use client";++import { useSession } from "next-auth/react";++import { UpgradeTip } from "@calcom/features/tips";+import { WEBAPP_URL } from "@calcom/lib/constants";+import { useLocale } from "@calcom/lib/hooks/useLocale";+import { Icon, Button, ButtonGroup } from "@calcom/ui";++export default function UpgradeTipWrapper({ children }: { children: React.ReactNode }) {+ const { t } = useLocale();+ const session = useSession();+ const features = [+ {+ icon: <Icon name="users" className="h-5 w-5" />,+ title: t("view_bookings_across"),+ description: t("view_bookings_across_description"),+ },+ {+ icon: <Icon name="refresh-ccw" className="h-5 w-5" />,+ title: t("identify_booking_trends"),+ description: t("identify_booking_trends_description"),+ },+ {+ icon: <Icon name="user-plus" className="h-5 w-5" />,+ title: t("spot_popular_event_types"),+ description: t("spot_popular_event_types_description"),+ },+ ];++ return (+ <UpgradeTip+ plan="team"+ title={t("make_informed_decisions")}+ description={t("make_informed_decisions_description")}+ features={features}+ background="/tips/insights"+ buttons={+ <div className="space-y-2 rtl:space-x-reverse sm:space-x-2">+ <ButtonGroup>+ <Button color="primary" href={`${WEBAPP_URL}/settings/teams/new`}>+ {t("create_team")}+ </Button>+ <Button color="minimal" href="https://go.cal.com/insights" target="_blank">+ {t("learn_more")}+ </Button>+ </ButtonGroup>+ </div>+ }>+ {!session.data?.user ? null : children}+ </UpgradeTip>+ );+}diff --git a/apps/web/app/(use-page-wrapper)/insights/layout.tsx b/apps/web/app/(use-page-wrapper)/insights/layout.tsxindex df6bd32be65..7aee590dde9 100644--- a/apps/web/app/(use-page-wrapper)/insights/layout.tsx+++ b/apps/web/app/(use-page-wrapper)/insights/layout.tsx@@ -1,65 +1,15 @@-"use client";--import { useSession } from "next-auth/react";+import { getTranslate } from "app/_utils";import Shell from "@calcom/features/shell/Shell";-import { UpgradeTip } from "@calcom/features/tips";-import { WEBAPP_URL } from "@calcom/lib/constants";-import { useLocale } from "@calcom/lib/hooks/useLocale";-import { Button, ButtonGroup } from "@calcom/ui";-import { Icon } from "@calcom/ui";--export default function InsightsLayout({ children }: { children: React.ReactNode }) {- const { t } = useLocale();- const session = useSession();- const features = [- {- icon: <Icon name="users" className="h-5 w-5" />,- title: t("view_bookings_across"),- description: t("view_bookings_across_description"),- },- {- icon: <Icon name="refresh-ccw" className="h-5 w-5" />,- title: t("identify_booking_trends"),- description: t("identify_booking_trends_description"),- },- {- icon: <Icon name="user-plus" className="h-5 w-5" />,- title: t("spot_popular_event_types"),- description: t("spot_popular_event_types_description"),- },- ];+import UpgradeTipWrapper from "./UpgradeTipWrapper";+export default async function InsightsLayout({ children }: { children: React.ReactNode }) {+ const t = await getTranslate();return (<div>- <Shell- withoutMain={false}- withoutSeo={true}- heading={t("insights")}- subtitle={t("insights_subtitle")}- title={t("insights")}- description={t("insights_subtitle")}>- <UpgradeTip- plan="team"- title={t("make_informed_decisions")}- description={t("make_informed_decisions_description")}- features={features}- background="/tips/insights"- buttons={- <div className="space-y-2 rtl:space-x-reverse sm:space-x-2">- <ButtonGroup>- <Button color="primary" href={`${WEBAPP_URL}/settings/teams/new`}>- {t("create_team")}- </Button>- <Button color="minimal" href="https://go.cal.com/insights" target="_blank">- {t("learn_more")}- </Button>- </ButtonGroup>- </div>- }>- {!session.data?.user ? null : children}- </UpgradeTip>+ <Shell withoutMain={false} withoutSeo={true} heading={t("insights")} subtitle={t("insights_subtitle")}>+ <UpgradeTipWrapper>{children}</UpgradeTipWrapper></Shell></div>);