import React, { useState } from "react"; import { useRouter } from "next/router"; // mobx import { useMobxStore } from "lib/mobx/store-provider"; import { observer } from "mobx-react-lite"; // headless ui import { Dialog, Transition } from "@headlessui/react"; // ui import { DangerButton, SecondaryButton } from "components/ui"; // icons import { AlertTriangle } from "lucide-react"; // types import { ICustomAttribute } from "types"; type Props = { isOpen: boolean; objectToDelete: ICustomAttribute | null; onClose: () => void; onSubmit?: () => Promise; }; export const DeleteObjectModal: React.FC = observer( ({ isOpen, objectToDelete, onClose, onSubmit }) => { const [isDeleting, setIsDeleting] = useState(false); const router = useRouter(); const { workspaceSlug } = router.query; const { customAttributes: customAttributesStore } = useMobxStore(); const { deleteEntity } = customAttributesStore; const handleClose = () => { onClose(); }; const handleDeleteObject = async () => { if (!workspaceSlug || !objectToDelete) return; setIsDeleting(true); await deleteEntity(workspaceSlug.toString(), objectToDelete.id) .then(async () => { if (onSubmit) await onSubmit(); handleClose(); }) .finally(() => setIsDeleting(false)); }; return (

Delete Object

Are you sure you want to delete object{" "} {objectToDelete?.display_name} ? The object will be deleted permanently and cannot be recovered.

Cancel {isDeleting ? "Deleting..." : "Delete Object"}
); } );