import React, { useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; // 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 { IWorkspaceView } from "types/workspace-views"; type Props = { data: IWorkspaceView; isOpen: boolean; onClose: () => void; }; export const DeleteGlobalViewModal: React.FC = observer((props) => { const { data, isOpen, onClose } = props; const [isDeleteLoading, setIsDeleteLoading] = useState(false); const router = useRouter(); const { workspaceSlug } = router.query; const { globalViews: globalViewsStore } = useMobxStore(); const { setToastAlert } = useToast(); const handleClose = () => { onClose(); }; const handleDeletion = async () => { if (!workspaceSlug) return; setIsDeleteLoading(true); await globalViewsStore .deleteGlobalView(workspaceSlug.toString(), data.id) .catch(() => setToastAlert({ type: "error", title: "Error!", message: "Something went wrong while deleting the view. Please try again.", }) ) .finally(() => { setIsDeleteLoading(false); handleClose(); }); // remove filters from local storage localStorage.removeItem(`global_view_filters/${data.id}`); }; 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.

); });