import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useState } from "react"; import { authClient } from "@kan/auth/client"; import Button from "~/components/Button"; import { useModal } from "~/providers/modal"; import { usePopup } from "~/providers/popup"; export function RevokeApiKeyConfirmation() { const { closeModal, entityId, entityLabel } = useModal(); const { showPopup } = usePopup(); const qc = useQueryClient(); const [isAcknowledgmentChecked, setIsAcknowledgmentChecked] = useState(false); const deleteApiKeyMutation = useMutation({ mutationFn: () => authClient.apiKey.delete({ keyId: entityId }), onSuccess: async () => { closeModal(); showPopup({ header: "API key revoked", message: `Your API key: ${entityLabel} has been revoked.`, icon: "success", }); qc.invalidateQueries({ queryKey: ["apiKeys"], }); }, onError: () => { closeModal(); showPopup({ header: "Error revoking API key", message: "Please try again later, or contact customer support.", icon: "error", }); }, }); const handleRevokeApiKey = () => { deleteApiKeyMutation.mutate(); }; return (
Keep in mind that this action is irreversible.
This will result in the permanent revocation of this API key.
I acknowledge that this API key will be permanently revoked and want to proceed.