From fd7f6c32ae3fe2bd5557b27c54e64b1b9e7a0692 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 7 Jan 2025 12:43:46 +0000 Subject: [PATCH] chore: Remove all instances of useIntercom (#18500) --- .../views/event-types-listing-view.tsx | 8 +- .../modules/settings/billing/billing-view.tsx | 6 +- .../platform/billing/billing-view.tsx | 6 +- .../ee/support/components/HelpMenuItem.tsx | 266 ------------------ packages/features/shell/Shell.tsx | 3 +- 5 files changed, 8 insertions(+), 281 deletions(-) delete mode 100644 packages/features/ee/support/components/HelpMenuItem.tsx diff --git a/apps/web/modules/event-types/views/event-types-listing-view.tsx b/apps/web/modules/event-types/views/event-types-listing-view.tsx index b3e6280f81..55e2b4a37c 100644 --- a/apps/web/modules/event-types/views/event-types-listing-view.tsx +++ b/apps/web/modules/event-types/views/event-types-listing-view.tsx @@ -9,7 +9,6 @@ import { memo, useEffect, useState } from "react"; import { z } from "zod"; import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider"; -import useIntercom from "@calcom/features/ee/support/lib/intercom/useIntercom"; import { EventTypeEmbedButton, EventTypeEmbedDialog } from "@calcom/features/embed/EventTypeEmbed"; import { EventTypeDescription } from "@calcom/features/eventtypes/components"; import CreateEventTypeDialog from "@calcom/features/eventtypes/components/CreateEventTypeDialog"; @@ -951,11 +950,9 @@ const EventTypesPage: React.FC & { getLayout?: AppProps["Component"]["getLayout"]; } = () => { const { t } = useLocale(); - const searchParams = useCompatSearchParams(); - const { open } = useIntercom(); const { data: user } = useMeQuery(); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [showProfileBanner, setShowProfileBanner] = useState(false); + const [_showProfileBanner, setShowProfileBanner] = useState(false); const orgBranding = useOrgBranding(); const routerQuery = useRouterQuery(); const filters = getTeamsFiltersFromQuery(routerQuery); @@ -973,9 +970,6 @@ const EventTypesPage: React.FC & { }); useEffect(() => { - if (searchParams?.get("openIntercom") === "true") { - open(); - } /** * During signup, if the account already exists, we redirect the user to /event-types instead of onboarding. * Adding this redirection logic here as well to ensure the user is redirected to the correct redirectUrl. diff --git a/apps/web/modules/settings/billing/billing-view.tsx b/apps/web/modules/settings/billing/billing-view.tsx index 880541e361..ea0bad0215 100644 --- a/apps/web/modules/settings/billing/billing-view.tsx +++ b/apps/web/modules/settings/billing/billing-view.tsx @@ -2,7 +2,6 @@ import { usePathname } from "next/navigation"; -import { useIntercom } from "@calcom/features/ee/support/lib/intercom/useIntercom"; import { classNames } from "@calcom/lib"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -32,12 +31,13 @@ export const CtaRow = ({ title, description, className, children }: CtaRowProps) const BillingView = () => { const pathname = usePathname(); const { t } = useLocale(); - const { open } = useIntercom(); const returnTo = pathname; const billingHref = `/api/integrations/stripepayment/portal?returnTo=${WEBAPP_URL}${returnTo}`; const onContactSupportClick = async () => { - await open(); + if (window.Plain) { + window.Plain.open(); + } }; return ( diff --git a/apps/web/modules/settings/platform/billing/billing-view.tsx b/apps/web/modules/settings/platform/billing/billing-view.tsx index 8c4d6d16b1..44096886c1 100644 --- a/apps/web/modules/settings/platform/billing/billing-view.tsx +++ b/apps/web/modules/settings/platform/billing/billing-view.tsx @@ -2,7 +2,6 @@ import { usePathname } from "next/navigation"; -import { useIntercom } from "@calcom/features/ee/support/lib/intercom/useIntercom"; import Shell from "@calcom/features/shell/Shell"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -17,12 +16,13 @@ import { CtaRow } from "~/settings/billing/billing-view"; export default function PlatformBillingUpgrade() { const pathname = usePathname(); const { t } = useLocale(); - const { open } = useIntercom(); const returnTo = pathname; const billingHref = `/api/integrations/stripepayment/portal?returnTo=${WEBAPP_URL}${returnTo}`; const onContactSupportClick = async () => { - await open(); + if (window.Plain) { + window.Plain.open(); + } }; const { isUserLoading, isUserBillingDataLoading, isPlatformUser, userBillingData, isPaidUser, userOrgId } = useGetUserAttributes(); diff --git a/packages/features/ee/support/components/HelpMenuItem.tsx b/packages/features/ee/support/components/HelpMenuItem.tsx deleted file mode 100644 index a1d84c7485..0000000000 --- a/packages/features/ee/support/components/HelpMenuItem.tsx +++ /dev/null @@ -1,266 +0,0 @@ -import { useState } from "react"; -import { useChat } from "react-live-chat-loader"; - -import classNames from "@calcom/lib/classNames"; -import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { localStorage } from "@calcom/lib/webstorage"; -import { trpc } from "@calcom/trpc/react"; -import { Button, showToast, TextArea } from "@calcom/ui"; -import { Icon } from "@calcom/ui"; - -import { useFreshChat } from "../lib/freshchat/FreshChatProvider"; -import { isFreshChatEnabled } from "../lib/freshchat/FreshChatScript"; -import { isInterComEnabled, useIntercom } from "../lib/intercom/useIntercom"; -import ContactMenuItem from "./ContactMenuItem"; - -interface HelpMenuItemProps { - onHelpItemSelect: () => void; -} - -export default function HelpMenuItem({ onHelpItemSelect }: HelpMenuItemProps) { - const [rating, setRating] = useState(null); - const [showIntercom, setShowIntercom] = useState( - localStorage.getItem("showIntercom") === "false" ? false : true - ); - const { open, shutdown } = useIntercom(); - const [comment, setComment] = useState(""); - const [disableSubmit, setDisableSubmit] = useState(true); - const [active, setActive] = useState(false); - const [, loadChat] = useChat(); - const { t } = useLocale(); - - const toggleIntercom = (value: boolean) => { - setShowIntercom(value); - localStorage.setItem("showIntercom", String(value)); - }; - - const { setActive: setFreshChat } = useFreshChat(); - - const mutation = trpc.viewer.submitFeedback.useMutation({ - onSuccess: () => { - setDisableSubmit(true); - showToast("Thank you, feedback submitted", "success"); - onHelpItemSelect(); - }, - }); - - const onRatingClick = (value: string) => { - setRating(value); - setDisableSubmit(false); - }; - - const sendFeedback = async (rating: string, comment: string) => { - mutation.mutate({ rating: rating, comment: comment }); - }; - - return ( -
-
-

{t("resources").toUpperCase()}

- onHelpItemSelect()} - href="https://cal.com/docs/" - target="_blank" - className="hover:bg-subtle hover:text-emphasis text-default flex w-full px-5 py-2 pr-4 text-sm font-medium transition" - rel="noreferrer"> - {t("documentation")} - - -
- -
-
-
-
-

{t("feedback").toUpperCase()}

-

{t("comments")}

- -