From 5c6f52f1d4c5a6ab111507adfa70600a1a3bf51a Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Sat, 15 Feb 2025 09:43:37 +0000 Subject: [PATCH] perf: separate client vs server code from insights layout (#19285) * add UpgradeTipWrapper * refactor insights/layout.tsx --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> --- .../insights/UpgradeTipWrapper.tsx | 53 ++++++++++++++++ .../(use-page-wrapper)/insights/layout.tsx | 62 ++----------------- 2 files changed, 59 insertions(+), 56 deletions(-) create mode 100644 apps/web/app/(use-page-wrapper)/insights/UpgradeTipWrapper.tsx diff --git a/apps/web/app/(use-page-wrapper)/insights/UpgradeTipWrapper.tsx b/apps/web/app/(use-page-wrapper)/insights/UpgradeTipWrapper.tsx new file mode 100644 index 0000000000..7ad886fee1 --- /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: , + title: t("view_bookings_across"), + description: t("view_bookings_across_description"), + }, + { + icon: , + title: t("identify_booking_trends"), + description: t("identify_booking_trends_description"), + }, + { + icon: , + title: t("spot_popular_event_types"), + description: t("spot_popular_event_types_description"), + }, + ]; + + return ( + + + + + + + }> + {!session.data?.user ? null : children} + + ); +} diff --git a/apps/web/app/(use-page-wrapper)/insights/layout.tsx b/apps/web/app/(use-page-wrapper)/insights/layout.tsx index df6bd32be6..7aee590dde 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: , - title: t("view_bookings_across"), - description: t("view_bookings_across_description"), - }, - { - icon: , - title: t("identify_booking_trends"), - description: t("identify_booking_trends_description"), - }, - { - icon: , - 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 (
- - - - - - -
- }> - {!session.data?.user ? null : children} - + + {children} );