import React, { useState } from "react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; import { AlertTriangle } from "lucide-react"; // ui import { Button, TOAST_TYPE, setToast } from "@plane/ui"; // hooks import { useProjectView } from "hooks/store"; // types import { IProjectView } from "@plane/types"; type Props = { data: IProjectView; isOpen: boolean; onClose: () => void; }; export const DeleteProjectViewModal: React.FC = observer((props) => { const { data, isOpen, onClose } = props; // states const [isDeleteLoading, setIsDeleteLoading] = useState(false); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // store hooks const { deleteView } = useProjectView(); const handleClose = () => { onClose(); setIsDeleteLoading(false); }; const handleDeleteView = async () => { if (!workspaceSlug || !projectId) return; setIsDeleteLoading(true); await deleteView(workspaceSlug.toString(), projectId.toString(), data.id) .then(() => { handleClose(); setToast({ type: TOAST_TYPE.SUCCESS, title: "Success!", message: "View deleted successfully.", }); }) .catch(() => setToast({ type: TOAST_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.

); });