Scheduling infrastructure for absolutely everyone.
fix: Added proper updates/interactivity on the "Getting started" app integ… (#17903)
Vincent Lam01b1f5bcc827
diff --git a/apps/web/components/getting-started/components/AppConnectionItem.tsx b/apps/web/components/getting-started/components/AppConnectionItem.tsxindex 895eb0e36d8..55f6464af5f 100644--- a/apps/web/components/getting-started/components/AppConnectionItem.tsx+++ b/apps/web/components/getting-started/components/AppConnectionItem.tsx@@ -1,4 +1,5 @@import Link from "next/link";+import { useState } from "react";import type { TDependencyData } from "@calcom/app-store/_appRegistry";import { InstallAppButtonWithoutPlanCheck } from "@calcom/app-store/components";@@ -6,7 +7,7 @@ import { WEBAPP_URL } from "@calcom/lib/constants";import { useLocale } from "@calcom/lib/hooks/useLocale";import { trpc } from "@calcom/trpc/react";import type { App } from "@calcom/types/App";-import { Badge, Button, Icon } from "@calcom/ui";+import { Badge, Button, Icon, showToast } from "@calcom/ui";interface IAppConnectionItem {title: string;@@ -25,6 +26,10 @@ const AppConnectionItem = (props: IAppConnectionItem) => {const { t } = useLocale();const setDefaultConferencingApp = trpc.viewer.appsRouter.setDefaultConferencingApp.useMutation();const dependency = props.dependencyData?.find((data) => !data.installed);++ const [isInstalling, setInstalling] = useState(false);+ const utils = trpc.useUtils();+return (<div className="flex flex-row items-center justify-between p-5"><div className="flex items-center space-x-3">@@ -39,6 +44,12 @@ const AppConnectionItem = (props: IAppConnectionItem) => {if (defaultInstall && slug) {setDefaultConferencingApp.mutate({ slug });}+ setInstalling(false);+ utils.viewer.integrations.invalidate();+ showToast(t("app_successfully_installed"), "success");+ },+ onError: (error) => {+ if (error instanceof Error) showToast(error.message || t("app_could_not_be_installed"), "error");},}}render={(buttonProps) => (@@ -47,7 +58,7 @@ const AppConnectionItem = (props: IAppConnectionItem) => {color="secondary"disabled={installed || !!dependency}type="button"- loading={buttonProps?.isPending}+ loading={isInstalling || buttonProps?.loading}tooltip={dependency ? (<div className="items-start space-x-2.5">@@ -86,6 +97,7 @@ const AppConnectionItem = (props: IAppConnectionItem) => {// Save cookie key to return url stepdocument.cookie = `return-to=${window.location.href};path=/;max-age=3600;SameSite=Lax`;buttonProps && buttonProps.onClick && buttonProps?.onClick(event);+ setInstalling(true);}}>{installed ? t("installed") : t("connect")}</Button>diff --git a/apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx b/apps/web/modules/getting-started/[[...step]]/onboarding-view.tsxindex 3bb63630a2e..9abf762cef6 100644--- a/apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx+++ b/apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx@@ -4,6 +4,7 @@ import { signOut } from "next-auth/react";import Head from "next/head";import { usePathname, useRouter } from "next/navigation";import { Suspense } from "react";+import { Toaster } from "react-hot-toast";import { z } from "zod";import { classNames } from "@calcom/lib";@@ -185,6 +186,7 @@ const OnboardingPage = (props: PageProps) => {</div></div></div>+ <Toaster position="bottom-right" /></div>);};diff --git a/packages/app-store/components.tsx b/packages/app-store/components.tsxindex 472b2ad10ab..fa704b98e42 100644--- a/packages/app-store/components.tsx+++ b/packages/app-store/components.tsx@@ -37,7 +37,7 @@ export const InstallAppButtonWithoutPlanCheck = (onClick: () => {mutation.mutate({ type: props.type });},- loading: mutation.isPending,+ loading: mutation.data?.setupPending,})}</>);