464343f5ab
* WIP * WIP * Type and migration fixes * Adds missing default import * Fixes import * Fixes tRPC imports in App Store * Migrate stripe helpers * WIP * Type fixes * Type fix? * WIP * WIP * Update index.ts * Fixes * Update workflow.tsx * Moved queries to lib * Moves QueryCell * Migrates MultiSelectCheckboxes * WIP * CryptoSection type fixes * WIP * Import fixes * Build fixes * Update app-providers.tsx * Build fixes * Upgrades hookform zod resolvers * Build fixes * Cleanup * Build fixes * Relocates QueryCell to ui * Moved List and SkeletonLoader * Revert QueryCell migration * Can't use QueryCell here * oops * CryptoSection cleanup * Update app-providers.tsx * Moved ee to features * ee to features/ee * Removes @calcom/ee * Adds possible feature locations * Build fixes * Migrates stripe to app-store lib * Colocates stripe imports * Update subscription.ts * Submodule sync Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.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 showToast from "@calcom/lib/notification";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import { ButtonBaseProps } from "@calcom/ui/Button";
|
|
import ConfirmationDialogContent from "@calcom/ui/ConfirmationDialogContent";
|
|
import { Dialog } from "@calcom/ui/Dialog";
|
|
|
|
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,
|
|
})}
|
|
</>
|
|
);
|
|
}
|