import React, { useState } from "react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; // ui import { AlertTriangle } from "lucide-react"; import { Dialog, Transition } from "@headlessui/react"; // icons import { IWorkspaceView } from "@plane/types"; // ui import { Button, TOAST_TYPE, setToast } from "@plane/ui"; // constants import { GLOBAL_VIEW_DELETED } from "@/constants/event-tracker"; // store hooks import { useGlobalView, useEventTracker } from "@/hooks/store"; // ui // types type Props = { data: IWorkspaceView; isOpen: boolean; onClose: () => void; }; export const DeleteGlobalViewModal: React.FC = observer((props) => { const { data, isOpen, onClose } = props; // states const [isDeleteLoading, setIsDeleteLoading] = useState(false); // router const router = useRouter(); const { workspaceSlug } = router.query; // store hooks const { deleteGlobalView } = useGlobalView(); const { captureEvent } = useEventTracker(); const handleClose = () => { onClose(); }; const handleDeletion = async () => { if (!workspaceSlug) return; setIsDeleteLoading(true); await deleteGlobalView(workspaceSlug.toString(), data.id) .then(() => { captureEvent(GLOBAL_VIEW_DELETED, { view_id: data.id, state: "SUCCESS", }); }) .catch(() => { captureEvent(GLOBAL_VIEW_DELETED, { view_id: data.id, state: "FAILED", }); setToast({ type: TOAST_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.

); });