Files
calendar/apps/web/components/integrations/DisconnectIntegration.tsx
T
89ef6c3f13 When deleting video app, change locations to Cal Video (#3022)
* tRPC endpoint to delete credentials

* Replace deleted app with daily

* Updated Jitisi logo

* Update logo size

* Update logo size

* Fix type error

* Remove type as prop

* Add isPrismaArray to lib

* Address feedback

* Remove connect calednar

* Expire payment sessions and cancel payment intent

* Expire payment sessions and cancel payment intent

* Refactor input

Co-authored-by: Omar López <zomars@me.com>

* Remove console.log

Co-authored-by: Omar López <zomars@me.com>

* Address feedback

* Find connected account on Stripe

* Fix type error

* Add interactive transactions

* Remove console.logs

* Remove console.log

Co-authored-by: Omar López <zomars@me.com>
2022-06-20 17:52:50 +00:00

60 lines
1.7 KiB
TypeScript

import { useState } from "react";
import { useMutation } from "react-query";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import showToast from "@calcom/lib/notification";
import { ButtonBaseProps } from "@calcom/ui/Button";
import { Dialog } from "@calcom/ui/Dialog";
import { trpc } from "@lib/trpc";
import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent";
export default function DisconnectIntegration(props: {
/** Integration credential id */
id: number;
render: (renderProps: ButtonBaseProps) => JSX.Element;
onOpenChange: (isOpen: boolean) => unknown | Promise<unknown>;
}) {
const { id } = 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 });
}}>
{t("are_you_sure_you_want_to_remove_this_app")}
</ConfirmationDialogContent>
</Dialog>
{props.render({
onClick() {
setModalOpen(true);
},
disabled: modalOpen,
loading: mutation.isLoading,
})}
</>
);
}