import React, { useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; // hooks import useToast from "hooks/use-toast"; import { useCycle, useIssues } from "hooks/store"; //icons import { ContrastIcon, TransferIcon } from "@plane/ui"; import { AlertCircle, Search, X } from "lucide-react"; // constants import { EIssuesStoreType } from "constants/issue"; 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 { setToastAlert } = useToast(); 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(() => { setToastAlert({ type: "success", title: "Issues transferred successfully", message: "Issues have been transferred successfully", }); }) .catch(() => { setToastAlert({ 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...

)}
); });