import React, { useState } from "react"; import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { Dialog, Transition } from "@headlessui/react"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // hooks import useToast from "hooks/use-toast"; // ui import { Button } from "@plane/ui"; // icons import { AlertTriangle } from "lucide-react"; // types import type { IPage } from "types"; type TConfirmPageDeletionProps = { data?: IPage | null; isOpen: boolean; onClose: () => void; }; export const DeletePageModal: React.FC = observer((props) => { const { data, isOpen, onClose } = props; const [isDeleting, setIsDeleting] = useState(false); const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { page: { deletePage }, } = useMobxStore(); const { setToastAlert } = useToast(); const handleClose = () => { setIsDeleting(false); onClose(); }; const handleDelete = async () => { if (!data || !workspaceSlug || !projectId) return; setIsDeleting(true); await deletePage(workspaceSlug.toString(), data.project, data.id) .then(() => { handleClose(); setToastAlert({ type: "success", title: "Success!", message: "Page deleted successfully.", }); }) .catch(() => { setToastAlert({ type: "error", title: "Error!", message: "Page could not be deleted. Please try again.", }); }) .finally(() => { setIsDeleting(false); }); }; return (
Delete Page

Are you sure you want to delete page-{" "} {data?.name}? The Page will be deleted permanently. This action cannot be undone.

); });