import React, { useState } from "react"; import { useRouter } from "next/router"; import useSWR, { mutate } from "swr"; import { Dialog, Transition } from "@headlessui/react"; // services import { CycleService } from "services/cycle.service"; // hooks import useToast from "hooks/use-toast"; import useIssuesView from "hooks/use-issues-view"; //icons import { ContrastIcon, TransferIcon } from "@plane/ui"; import { AlertCircle, Search, X } from "lucide-react"; // fetch-key import { CYCLE_ISSUES_WITH_PARAMS, 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 = ({ isOpen, handleClose }) => { const [query, setQuery] = useState(""); const router = useRouter(); const { workspaceSlug, projectId, cycleId } = router.query; const { params } = useIssuesView(); const { setToastAlert } = useToast(); const transferIssue = async (payload: any) => { await cycleService .transferIssues(workspaceSlug as string, projectId as string, cycleId as string, payload) .then(() => { mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params)); 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...

)}
); };