* dumb components for calendar settings * shadcn switch * update exports * update packages * add calendar settings atom to examples app * init calendar settings atom * refactors * fix import path * export type for calendar switch props * invalidate queries on deleting calendar credentials * replace calendars list with calendar settings wrapper * cleanup * update styling * refactors * cleanup * fix: missing key prop CalendarSettingsPlatformWrapper * Label as client components * Address client component build errors * Move QueryCell out of packages/lib * PR feedback * more feedback --------- Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Co-authored-by: Morgan Vernay <morgan@cal.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import type { ButtonProps } from "@calcom/ui";
|
|
import { DisconnectIntegrationComponent, showToast } from "@calcom/ui";
|
|
|
|
export default function DisconnectIntegration(props: {
|
|
credentialId: number;
|
|
label?: string;
|
|
trashIcon?: boolean;
|
|
isGlobal?: boolean;
|
|
onSuccess?: () => void;
|
|
buttonProps?: ButtonProps;
|
|
}) {
|
|
const { t } = useLocale();
|
|
const { onSuccess, credentialId } = props;
|
|
const [modalOpen, setModalOpen] = useState(false);
|
|
const utils = trpc.useUtils();
|
|
|
|
const mutation = trpc.viewer.deleteCredential.useMutation({
|
|
onSuccess: () => {
|
|
showToast(t("app_removed_successfully"), "success");
|
|
setModalOpen(false);
|
|
onSuccess && onSuccess();
|
|
},
|
|
onError: () => {
|
|
showToast(t("error_removing_app"), "error");
|
|
setModalOpen(false);
|
|
},
|
|
async onSettled() {
|
|
await utils.viewer.connectedCalendars.invalidate();
|
|
await utils.viewer.integrations.invalidate();
|
|
},
|
|
});
|
|
|
|
return (
|
|
<DisconnectIntegrationComponent
|
|
onDeletionConfirmation={() => mutation.mutate({ id: credentialId })}
|
|
isModalOpen={modalOpen}
|
|
onModalOpen={() => setModalOpen((prevValue) => !prevValue)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|