import React, { useState } from "react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { AlertCircle, Search, X } from "lucide-react"; import { Dialog, Transition } from "@headlessui/react"; // hooks // ui //icons import { ContrastIcon, TransferIcon, TOAST_TYPE, setToast } from "@plane/ui"; import { EIssuesStoreType } from "@/constants/issue"; import { useCycle, useIssues } from "@/hooks/store"; //icons // constants type Props = { isOpen: boolean; handleClose: () => void; }; export const TransferIssuesModal: React.FC = observer((props) => { const { isOpen, handleClose } = props; // states const [query, setQuery] = useState(""); // store hooks const { currentProjectIncompleteCycleIds, getCycleById } = useCycle(); const { issues: { transferIssuesFromCycle }, } = useIssues(EIssuesStoreType.CYCLE); const router = useRouter(); const { workspaceSlug, projectId, cycleId } = router.query; const transferIssue = async (payload: any) => { if (!workspaceSlug || !projectId || !cycleId) return; // TODO: import transferIssuesFromCycle from store await transferIssuesFromCycle(workspaceSlug.toString(), projectId.toString(), cycleId.toString(), payload) .then(() => { setToast({ type: TOAST_TYPE.SUCCESS, title: "Issues transferred successfully", message: "Issues have been transferred successfully", }); }) .catch(() => { setToast({ type: TOAST_TYPE.ERROR, title: "Error!", message: "Issues cannot be transfer. Please try again.", }); }); }; const filteredOptions = currentProjectIncompleteCycleIds?.filter((optionId) => { const cycleDetails = getCycleById(optionId); return cycleDetails?.name?.toLowerCase().includes(query?.toLowerCase()); }); // useEffect(() => { // const handleKeyDown = (e: KeyboardEvent) => { // if (e.key === "Escape") { // handleClose(); // } // }; // }, [handleClose]); return (

Transfer Issues

setQuery(e.target.value)} value={query} />
{filteredOptions ? ( filteredOptions.length > 0 ? ( filteredOptions.map((optionId) => { const cycleDetails = getCycleById(optionId); if (!cycleDetails) return; return ( ); }) ) : (
You don’t have any current cycle. Please create one to transfer the issues.
) ) : (

Loading...

)}
); });