mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 06:29:04 +00:00
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { createNotification } from "@app/components/notifications";
|
|
import { DeleteActionModal } from "@app/components/v2";
|
|
import { TPamAccount, useDeletePamAccount } from "@app/hooks/api/pam";
|
|
|
|
type Props = {
|
|
account?: TPamAccount;
|
|
isOpen: boolean;
|
|
onOpenChange: (isOpen: boolean) => void;
|
|
};
|
|
|
|
export const PamDeleteAccountModal = ({ isOpen, onOpenChange, account }: Props) => {
|
|
const deletePamAccount = useDeletePamAccount();
|
|
|
|
if (!account) return null;
|
|
|
|
const {
|
|
id: accountId,
|
|
name,
|
|
resource: { resourceType }
|
|
} = account;
|
|
|
|
const handleDelete = async () => {
|
|
await deletePamAccount.mutateAsync({
|
|
accountId,
|
|
resourceType
|
|
});
|
|
|
|
createNotification({
|
|
text: "Successfully deleted account",
|
|
type: "success"
|
|
});
|
|
|
|
onOpenChange(false);
|
|
};
|
|
|
|
return (
|
|
<DeleteActionModal
|
|
isOpen={isOpen}
|
|
onChange={onOpenChange}
|
|
title={`Are you sure you want to delete ${name}?`}
|
|
deleteKey={name}
|
|
onDeleteApproved={handleDelete}
|
|
/>
|
|
);
|
|
};
|