+9








e044f963f8
Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: MuriloAmarals <muralha2000@gmail.com> Co-authored-by: Murilo Amaral <87545137+MuriloAmarals@users.noreply.github.com> Co-authored-by: Rubens Rafael <70234898+RubensRafael@users.noreply.github.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: Rafael Toledo <87545086+Toledodev@users.noreply.github.com> Co-authored-by: gitstart <gitstart@gitstart.com> Co-authored-by: Rafael <rafael.toledo@engenharia.ufjf.br> Co-authored-by: Grace Nshokano <grace.devolop@gmail.com> Co-authored-by: Matheus Muniz <matheusmuniz100@hotmail.com> Co-authored-by: Júlio Piubello da Silva Cabral <julio.piubello@gitstart.dev> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Co-authored-by: Matheus Benini Ferreira <88898100+MatheusBeniniF@users.noreply.github.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: C000Ldude <coolmagnas@gmail.com> Co-authored-by: Klinger Matheus <50892465+KlingerMatheus@users.noreply.github.com> Co-authored-by: Eman <emmanuelgatwech@gmail.com>
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { useState } from "react";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import { ButtonBaseProps } from "@calcom/ui/Button";
|
|
import ConfirmationDialogContent from "@calcom/ui/ConfirmationDialogContent";
|
|
import { Dialog } from "@calcom/ui/Dialog";
|
|
import showToast from "@calcom/ui/v2/core/notifications";
|
|
|
|
export default function DisconnectIntegration(props: {
|
|
/** Integration credential id */
|
|
id: number;
|
|
externalId?: string;
|
|
render: (renderProps: ButtonBaseProps) => JSX.Element;
|
|
onOpenChange: (isOpen: boolean) => unknown | Promise<unknown>;
|
|
}) {
|
|
const { id, externalId = "" } = props;
|
|
const { t } = useLocale();
|
|
const [modalOpen, setModalOpen] = useState(false);
|
|
|
|
const mutation = trpc.useMutation("viewer.deleteCredential", {
|
|
onSettled: async () => {
|
|
await props.onOpenChange(modalOpen);
|
|
},
|
|
onSuccess: () => {
|
|
showToast("Integration deleted successfully", "success");
|
|
setModalOpen(false);
|
|
},
|
|
onError: () => {
|
|
throw new Error("Something went wrong");
|
|
},
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<Dialog open={modalOpen} onOpenChange={setModalOpen}>
|
|
<ConfirmationDialogContent
|
|
variety="danger"
|
|
title={t("remove_app")}
|
|
confirmBtnText={t("yes_remove_app")}
|
|
cancelBtnText="Cancel"
|
|
onConfirm={() => {
|
|
mutation.mutate({ id, externalId });
|
|
}}>
|
|
{t("are_you_sure_you_want_to_remove_this_app")}
|
|
</ConfirmationDialogContent>
|
|
</Dialog>
|
|
{props.render({
|
|
onClick() {
|
|
setModalOpen(true);
|
|
},
|
|
disabled: modalOpen,
|
|
loading: mutation.isLoading,
|
|
})}
|
|
</>
|
|
);
|
|
}
|