import React, { useState } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { Dialog, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; // services import { CycleService } from "services/cycle.service"; // hooks import useToast from "hooks/use-toast"; import { useMobxStore } from "lib/mobx/store-provider"; //icons import { ContrastIcon, TransferIcon } from "@plane/ui"; import { AlertCircle, Search, X } from "lucide-react"; // fetch-key import { INCOMPLETE_CYCLES_LIST } from "constants/fetch-keys"; // types import { ICycle } from "types"; //helper import { getDateRangeStatus } from "helpers/date-time.helper"; type Props = { isOpen: boolean; handleClose: () => void; }; const cycleService = new CycleService(); export const TransferIssuesModal: React.FC = observer(({ isOpen, handleClose }) => { const [query, setQuery] = useState(""); const { cycleIssues: cycleIssueStore } = useMobxStore(); const router = useRouter(); const { workspaceSlug, projectId, cycleId } = router.query; const { setToastAlert } = useToast(); const transferIssue = async (payload: any) => { await cycleIssueStore .transferIssuesFromCycle(workspaceSlug as string, projectId as string, cycleId as string, payload) .then(() => { setToastAlert({ type: "success", title: "Issues transfered successfully", message: "Issues have been transferred successfully", }); }) .catch(() => { setToastAlert({ type: "error", title: "Error!", message: "Issues cannot be transfer. Please try again.", }); }); }; const { data: incompleteCycles } = useSWR( workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null, workspaceSlug && projectId ? () => cycleService.getCyclesWithParams(workspaceSlug as string, projectId as string, "incomplete") : null ); const filteredOptions = query === "" ? incompleteCycles : incompleteCycles?.filter((option) => option.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((option: ICycle) => ( )) ) : (
You don’t have any current cycle. Please create one to transfer the issues.
) ) : (

Loading...

)}
); });