// react import React, { useState } from "react"; // next import Link from "next/link"; // swr import useSWR, { mutate } from "swr"; // headless ui import { Disclosure, Transition, Menu } from "@headlessui/react"; // services import cycleServices from "lib/services/cycles.services"; // hooks import useUser from "lib/hooks/useUser"; // components import CycleIssuesListModal from "./CycleIssuesListModal"; // ui import { Spinner } from "ui"; // icons import { PlusIcon, EllipsisHorizontalIcon, ChevronDownIcon } from "@heroicons/react/20/solid"; // types import type { CycleViewProps as Props, CycleIssueResponse, IssueResponse } from "types"; // fetch keys import { CYCLE_ISSUES } from "constants/fetch-keys"; // constants import { renderShortNumericDateFormat } from "constants/common"; import issuesServices from "lib/services/issues.services"; import StrictModeDroppable from "components/dnd/StrictModeDroppable"; import { Draggable } from "react-beautiful-dnd"; const CycleView: React.FC = ({ cycle, selectSprint, workspaceSlug, projectId, openIssueModal, }) => { const [cycleIssuesListModal, setCycleIssuesListModal] = useState(false); const { activeWorkspace, activeProject, issues } = useUser(); const { data: cycleIssues } = useSWR(CYCLE_ISSUES(cycle.id), () => cycleServices.getCycleIssues(workspaceSlug, projectId, cycle.id) ); const removeIssueFromCycle = (cycleId: string, bridgeId: string) => { if (activeWorkspace && activeProject && cycleIssues) { mutate( CYCLE_ISSUES(cycleId), (prevData) => prevData?.filter((p) => p.id !== bridgeId), false ); issuesServices .removeIssueFromCycle(activeWorkspace.slug, activeProject.id, cycleId, bridgeId) .then((res) => { console.log(res); }) .catch((e) => { console.log(e); }); } }; return ( <> setCycleIssuesListModal(false)} issues={issues} cycleId={cycle.id} /> {({ open }) => (

{cycle.name}

{cycle.status === "started" ? cycle.start_date ? `${renderShortNumericDateFormat(cycle.start_date)} - ` : "" : cycle.status} {cycle.end_date ? renderShortNumericDateFormat(cycle.end_date) : ""}

{(provided) => (
{cycleIssues ? ( cycleIssues.length > 0 ? ( cycleIssues.map((issue, index) => ( {(provided, snapshot) => (
{issue.issue_details.state_detail?.name}
)}
)) ) : (

This cycle has no issue.

) ) : (
)} {provided.placeholder}
)}
Add issue
{(active) => ( )} {(active) => ( )}
)}
); }; export default CycleView;