diff --git a/apps/web/lib/app-providers.tsx b/apps/web/lib/app-providers.tsx index dd7b3b2f53..2d926f54bd 100644 --- a/apps/web/lib/app-providers.tsx +++ b/apps/web/lib/app-providers.tsx @@ -17,7 +17,6 @@ import { OrgBrandingProvider } from "@calcom/features/ee/organizations/context/p import DynamicHelpscoutProvider from "@calcom/features/ee/support/lib/helpscout/providerDynamic"; import { FeatureProvider } from "@calcom/features/flags/context/provider"; import { useFlags } from "@calcom/features/flags/hooks"; -import { MetaProvider } from "@calcom/ui"; import useIsBookingPage from "@lib/hooks/useIsBookingPage"; import type { WithLocaleProps } from "@lib/withLocale"; @@ -303,9 +302,7 @@ const AppProviders = (props: AppPropsWithChildren) => { isBookingPage={props.Component.isBookingPage || isBookingPage} router={props.router}> - - {props.children} - + {props.children} diff --git a/apps/web/modules/settings/developer/api-keys-view.tsx b/apps/web/modules/settings/developer/api-keys-view.tsx index 71e8e77129..0a25ffd23c 100644 --- a/apps/web/modules/settings/developer/api-keys-view.tsx +++ b/apps/web/modules/settings/developer/api-keys-view.tsx @@ -11,7 +11,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Button, Dialog, DialogContent, EmptyScreen, SkeletonContainer, SkeletonText } from "@calcom/ui"; -const SkeletonLoader = ({ title, description }: { title: string; description: string }) => { +const SkeletonLoader = () => { return (
@@ -64,12 +64,7 @@ const ApiKeysView = () => { }, []); if (isPending || !data) { - return ( - - ); + return ; } return ( diff --git a/packages/app-store/routing-forms/components/SingleForm.tsx b/packages/app-store/routing-forms/components/SingleForm.tsx index 5042091bfe..54140b25e4 100644 --- a/packages/app-store/routing-forms/components/SingleForm.tsx +++ b/packages/app-store/routing-forms/components/SingleForm.tsx @@ -28,7 +28,6 @@ import { DialogHeader, DropdownMenuSeparator, Form, - Meta, SettingsToggle, showToast, TextAreaField, @@ -761,7 +760,6 @@ function SingleForm({ form, appUrl, Page, enrichedWithUserProfileForm }: SingleF appUrl={appUrl} newFormDialogState={newFormDialogState} setNewFormDialogState={setNewFormDialogState}> - diff --git a/packages/features/ee/organizations/pages/settings/attributes/attributes-create-view.tsx b/packages/features/ee/organizations/pages/settings/attributes/attributes-create-view.tsx index 0916c468f3..b43649c020 100644 --- a/packages/features/ee/organizations/pages/settings/attributes/attributes-create-view.tsx +++ b/packages/features/ee/organizations/pages/settings/attributes/attributes-create-view.tsx @@ -7,7 +7,7 @@ import { z } from "zod"; import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; -import { Button, useMeta, showToast } from "@calcom/ui"; +import { Button, showToast } from "@calcom/ui"; import { AttributeForm } from "./AttributesForm"; @@ -51,7 +51,6 @@ function CreateAttributesPage() { } function CreateAttributeHeader(props: { isPending: boolean }) { - const { meta } = useMeta(); const { t } = useLocale(); const formContext = useFormContext(); @@ -69,7 +68,7 @@ function CreateAttributeHeader(props: { isPending: boolean }) { {t("back_to_attributes")}
-

{meta.title || t("attribute")}

+

{t("attribute")}

{watchedTitle && ( <> / {watchedTitle} diff --git a/packages/features/ee/organizations/pages/settings/attributes/attributes-edit-view.tsx b/packages/features/ee/organizations/pages/settings/attributes/attributes-edit-view.tsx index 0ad45ce6b8..12aa4cca0d 100644 --- a/packages/features/ee/organizations/pages/settings/attributes/attributes-edit-view.tsx +++ b/packages/features/ee/organizations/pages/settings/attributes/attributes-edit-view.tsx @@ -7,7 +7,7 @@ import { z } from "zod"; import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; -import { Button, useMeta, showToast } from "@calcom/ui"; +import { Button, showToast } from "@calcom/ui"; import { AttributeForm } from "./AttributesForm"; @@ -73,7 +73,6 @@ function CreateAttributesPage() { } function EditAttributeHeader(props: { isPending: boolean }) { - const { meta } = useMeta(); const { t } = useLocale(); const formContext = useFormContext(); @@ -91,7 +90,7 @@ function EditAttributeHeader(props: { isPending: boolean }) { {t("back_to_attributes")}
-

{meta.title || t("attribute")}

+

{t("attribute")}

{watchedTitle && ( <> / {watchedTitle} diff --git a/packages/features/ee/organizations/pages/settings/profile.tsx b/packages/features/ee/organizations/pages/settings/profile.tsx index ac4a82000a..440997d8a5 100644 --- a/packages/features/ee/organizations/pages/settings/profile.tsx +++ b/packages/features/ee/organizations/pages/settings/profile.tsx @@ -57,7 +57,7 @@ type FormValues = { calVideoLogo: string | null; }; -const SkeletonLoader = ({ title, description }: { title: string; description: string }) => { +const SkeletonLoader = () => { return (
@@ -101,7 +101,7 @@ const OrgProfileView = () => { ); if (isPending || !orgBranding || !currentOrganisation) { - return ; + return ; } const isOrgAdminOrOwner = diff --git a/packages/features/ee/sso/components/SSOConfiguration.tsx b/packages/features/ee/sso/components/SSOConfiguration.tsx index 0a88724b26..5b12d01880 100644 --- a/packages/features/ee/sso/components/SSOConfiguration.tsx +++ b/packages/features/ee/sso/components/SSOConfiguration.tsx @@ -4,12 +4,11 @@ import OIDCConnection from "@calcom/features/ee/sso/components/OIDCConnection"; import SAMLConnection from "@calcom/features/ee/sso/components/SAMLConnection"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; -import { Meta, Alert, SkeletonContainer, SkeletonText } from "@calcom/ui"; +import { Alert, SkeletonContainer, SkeletonText } from "@calcom/ui"; -const SkeletonLoader = ({ title, description }: { title: string; description: string }) => { +const SkeletonLoader = () => { return ( -
@@ -25,17 +24,12 @@ export default function SSOConfiguration({ teamId }: { teamId: number | null }) const { data: connection, isPending, error } = trpc.viewer.saml.get.useQuery({ teamId }); if (isPending) { - return ; + return ; } if (error) { return ( <> - ); diff --git a/packages/features/ee/sso/page/orgs-sso-view.tsx b/packages/features/ee/sso/page/orgs-sso-view.tsx index 15cbe6b505..7db14ff84b 100644 --- a/packages/features/ee/sso/page/orgs-sso-view.tsx +++ b/packages/features/ee/sso/page/orgs-sso-view.tsx @@ -14,8 +14,7 @@ const SAMLSSO = () => { const { data, status } = useSession(); const org = data?.user.org; - if (status === "loading") - ; + if (status === "loading") ; if (!org) { return null; diff --git a/packages/ui/components/apps/SkeletonLoader.tsx b/packages/ui/components/apps/SkeletonLoader.tsx index 31165686a9..6a0ca1debe 100644 --- a/packages/ui/components/apps/SkeletonLoader.tsx +++ b/packages/ui/components/apps/SkeletonLoader.tsx @@ -1,21 +1,10 @@ import { ShellSubHeading } from "../layout"; -import Meta from "../meta/Meta"; import { SkeletonText } from "../skeleton"; -export function SkeletonLoader({ - className, - title, - description, -}: { - className?: string; - title?: string; - description?: string; -}) { +export function SkeletonLoader({ className }: { className?: string }) { return ( <> } {...{ className }} /> - {title && description && } -
    diff --git a/packages/ui/components/meta/Meta.tsx b/packages/ui/components/meta/Meta.tsx deleted file mode 100644 index 58ca372a16..0000000000 --- a/packages/ui/components/meta/Meta.tsx +++ /dev/null @@ -1,69 +0,0 @@ -"use client"; - -import Head from "next/head"; -import { createContext, useContext, useState, useEffect } from "react"; -import type { ReactNode } from "react"; - -import { APP_NAME } from "@calcom/lib/constants"; - -type MetaType = { - title: string; - description: string; - backButton?: boolean; - CTA?: ReactNode; - borderInShellHeader?: boolean; -}; - -const initialMeta: MetaType = { - title: "", - description: "", - backButton: false, - CTA: null, - borderInShellHeader: true, -}; - -const MetaContext = createContext({ - meta: initialMeta, - // eslint-disable-next-line @typescript-eslint/no-empty-function - setMeta: (_newMeta: Partial) => {}, -}); - -export function useMeta() { - return useContext(MetaContext); -} - -export function MetaProvider({ children }: { children: ReactNode }) { - const [value, setValue] = useState(initialMeta); - const setMeta = (newMeta: Partial) => { - setValue((v) => ({ ...v, ...newMeta })); - }; - - return {children}; -} - -/** - * The purpose of this component is to simplify title and description handling. - * Similarly to `next/head`'s `Head` component this allow us to update the metadata for a page - * from any children, also exposes the metadata via the `useMeta` hook in case we need them - * elsewhere (ie. on a Heading, Title, Subtitle, etc.) - * @example - */ -export default function Meta({ title, description, backButton, CTA, borderInShellHeader }: MetaType) { - const { setMeta, meta } = useMeta(); - - /* @TODO: maybe find a way to have this data on first render to prevent flicker */ - useEffect(() => { - if (meta.title !== title || meta.description !== description || meta.CTA !== CTA) { - setMeta({ title, description, backButton, CTA, borderInShellHeader }); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [title, description, backButton, CTA]); - - const title_ = `${title} | ${APP_NAME}`; - return ( - - {title_} - - - ); -} diff --git a/packages/ui/components/meta/index.ts b/packages/ui/components/meta/index.ts deleted file mode 100644 index f11468d4e1..0000000000 --- a/packages/ui/components/meta/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Meta, MetaProvider, useMeta } from "./Meta"; diff --git a/packages/ui/components/meta/meta.test.tsx b/packages/ui/components/meta/meta.test.tsx deleted file mode 100644 index 6c9edaa83d..0000000000 --- a/packages/ui/components/meta/meta.test.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { render } from "@testing-library/react"; -import { vi } from "vitest"; - -import Meta, { useMeta } from "./Meta"; - -vi.mock("./Meta", async () => { - const actualMeta = (await vi.importActual("./Meta")) as object; - const MockMeta = ({ title, description }: { title: string; description: string }) => ( -
    -

    {title}

    -

    {description}

    -
    - ); - - type MetaProviderProps = { - children: React.ReactNode; - }; - - return { - ...actualMeta, - default: MockMeta, - useMeta: vi.fn(), - MetaProvider: ({ children }: MetaProviderProps) => children, - }; -}); - -describe("Meta Component", () => { - test("Should render with default metadata", () => { - (useMeta as jest.Mock).mockReturnValue({ - meta: { title: "", description: "", backButton: false, CTA: null }, - }); - - const { getByText } = render(); - - expect(getByText("Page Title")).toBeInTheDocument(); - expect(getByText("Page Description")).toBeInTheDocument(); - }); - - test("Should update metadata when props change", () => { - (useMeta as jest.Mock).mockReturnValue({ - meta: { title: "", description: "", backButton: false, CTA: null }, - }); - - const { rerender, getByText } = render(); - - expect(getByText("Page Title")).toBeInTheDocument(); - expect(getByText("Page Description")).toBeInTheDocument(); - - rerender(); - - expect(getByText("New Title")).toBeInTheDocument(); - expect(getByText("New Description")).toBeInTheDocument(); - }); -}); diff --git a/packages/ui/index.ts b/packages/ui/index.ts index b9385a946d..1027668d48 100644 --- a/packages/ui/index.ts +++ b/packages/ui/index.ts @@ -124,7 +124,6 @@ export { AppListCard } from "./components/app-list-card"; export { DisconnectIntegrationComponent } from "./components/disconnect-calendar-integration"; export { CalendarSwitchComponent } from "./components/calendar-switch"; export { showToast, ErrorToast, SuccessToast, WarningToast } from "./components/toast"; // We don't export the toast components as they are only used in local storybook file -export { Meta, MetaProvider, useMeta } from "./components/meta"; export { ShellSubHeading } from "./components/layout"; /** ⬇️ TODO - Move these to components */