"use client"; import { AlertTriangle, Trash2Icon } from "lucide-react"; import { revokeApiKey } from "@/actions/api-keys/api-keys"; import { Alert, AlertDescription, AlertTitle } from "@/components/shadcn/alert"; import { CodeSnippet } from "@/components/shadcn/code-snippet/code-snippet"; import { ModalButtons } from "@/components/shadcn/custom/custom-modal-buttons"; import { Modal } from "@/components/shadcn/modal"; import { FALLBACK_VALUES } from "./api-keys/constants"; import { EnrichedApiKey } from "./api-keys/types"; import { useModalForm } from "./api-keys/use-modal-form"; interface RevokeApiKeyModalProps { isOpen: boolean; onClose: () => void; apiKey: EnrichedApiKey | null; onSuccess: () => void; } export const RevokeApiKeyModal = ({ isOpen, onClose, apiKey, onSuccess, }: RevokeApiKeyModalProps) => { const { isLoading, error, handleSubmit, handleClose } = useModalForm({ initialData: {}, onSubmit: async () => { if (!apiKey) { throw new Error("No API key selected"); } const result = await revokeApiKey(apiKey.id); if (result.error) { throw new Error(result.error); } onSuccess(); }, onSuccess, onClose, }); return ( !open && handleClose()} title="Revoke API Key" size="lg" >
Warning This action cannot be undone. This API key will be revoked and will no longer work.

Are you sure you want to revoke this API key?

{error && ( {error} )}
} />
); };