Files
calendar/packages/features/ee/organizations/pages/settings/attributes/DeleteAttributeModal.tsx
T
aaf630f01f feat: Delete attribute modal (#17557)
* feat: Delete attribute modal

* move Modal file

---------

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
2024-11-11 08:33:19 +00:00

48 lines
1.4 KiB
TypeScript

import type { Dispatch, SetStateAction } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { RouterOutputs } from "@calcom/trpc/react";
import { trpc } from "@calcom/trpc/react";
import { Dialog, ConfirmationDialogContent, showToast } from "@calcom/ui";
type AttributeItemProps = RouterOutputs["viewer"]["attributes"]["list"][number];
export function DeleteAttributeModal({
attributeToDelete,
setAttributeToDelete,
}: {
attributeToDelete: AttributeItemProps;
setAttributeToDelete: Dispatch<SetStateAction<AttributeItemProps | undefined>>;
}) {
const { t } = useLocale();
const utils = trpc.useUtils();
const deleteMutation = trpc.viewer.attributes.delete.useMutation({
onSuccess: () => {
showToast(t("attribute_deleted_successfully"), "success");
utils.viewer.attributes.list.invalidate();
},
onError: (err) => {
showToast(err.message, "error");
},
});
return (
<Dialog open={true} onOpenChange={() => setAttributeToDelete(undefined)}>
<ConfirmationDialogContent
variety="danger"
title={t("remove_attribute")}
confirmBtnText={t("confirm_remove_attribute")}
onConfirm={() => {
deleteMutation.mutate({
id: attributeToDelete.id,
});
}}>
{t("remove_attribute_confirmation_message", {
name: attributeToDelete.name,
})}
</ConfirmationDialogContent>
</Dialog>
);
}