fix: Added proper updates/interactivity on the "Getting started" app integ… (#17903)
* Added proper updates/interactivity on the "Getting started" app integrations. - InstallAppButtonWithoutPlanCheck properly vends the mutation data in the render's props - Fixed the improper props wiring in the AppConnectionItem - Added a loading state for reactivity * -Added toaster for error/success confirmation
This commit is contained in:
1 parent
953a8119db
commit
01b1f5bcc8
3 files changed
+17
-3
No files matched your search
@@ -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 step
|
||||
document.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>
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ export const InstallAppButtonWithoutPlanCheck = (
|
||||
onClick: () => {
|
||||
mutation.mutate({ type: props.type });
|
||||
},
|
||||
loading: mutation.isPending,
|
||||
loading: mutation.data?.setupPending,
|
||||
})}
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user