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 { IProjectView } from "types"; type Props = { data: IProjectView; isOpen: boolean; onClose: () => void; }; export const DeleteProjectViewModal: React.FC = observer((props) => { const { data, isOpen, onClose } = props; const [isDeleteLoading, setIsDeleteLoading] = useState(false); const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { projectViews: projectViewsStore } = useMobxStore(); const { setToastAlert } = useToast(); const handleClose = () => { onClose(); setIsDeleteLoading(false); }; const handleDeleteView = async () => { if (!workspaceSlug || !projectId) return; setIsDeleteLoading(true); await projectViewsStore .deleteView(workspaceSlug.toString(), projectId.toString(), data.id) .then(() => { handleClose(); setToastAlert({ type: "success", title: "Success!", message: "View deleted successfully.", }); }) .catch(() => setToastAlert({ type: "error", title: "Error!", message: "View could not be deleted. Please try again.", }) ) .finally(() => { setIsDeleteLoading(false); }); }; return (
Delete View

Are you sure you want to delete view-{" "} {data?.name}? All of the data related to the view will be permanently removed. This action cannot be undone.

); });