import React, { useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; // hooks import { useLabel } from "hooks/store"; // icons import { AlertTriangle } from "lucide-react"; // hooks import useToast from "hooks/use-toast"; // ui import { Button } from "@plane/ui"; // types import type { IIssueLabel } from "@plane/types"; type Props = { isOpen: boolean; onClose: () => void; data: IIssueLabel | null; }; export const DeleteLabelModal: React.FC = observer((props) => { const { isOpen, onClose, data } = props; // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // store hooks const { project: { deleteLabel }, } = useLabel(); // states const [isDeleteLoading, setIsDeleteLoading] = useState(false); // hooks const { setToastAlert } = useToast(); const handleClose = () => { onClose(); setIsDeleteLoading(false); }; const handleDeletion = async () => { if (!workspaceSlug || !projectId || !data) return; setIsDeleteLoading(true); await deleteLabel(workspaceSlug.toString(), projectId.toString(), data.id) .then(() => { handleClose(); }) .catch((err) => { setIsDeleteLoading(false); const error = err?.error || "Label could not be deleted. Please try again."; setToastAlert({ type: "error", title: "Error!", message: error, }); }); }; return (
Delete Label

Are you sure you want to delete label-{" "} {data?.name}? The label will be removed from all the issues.

); });