import React from "react"; // next import { useRouter } from "next/router"; // swr import useSWR from "swr"; // headless ui import { Disclosure, Transition, Menu, Listbox } from "@headlessui/react"; // fetch keys import { PROJECT_ISSUES_LIST, CYCLE_ISSUES } from "constants/fetch-keys"; // services import issuesServices from "lib/services/issues.services"; import cycleServices from "lib/services/cycles.services"; // commons import { classNames, renderShortNumericDateFormat } from "constants/common"; // ui import { Spinner } from "ui"; // icons import { PlusIcon, EllipsisHorizontalIcon, ChevronDownIcon } from "@heroicons/react/20/solid"; // types import type { ICycle, SprintViewProps as Props, SprintIssueResponse, IssueResponse } from "types"; const SprintView: React.FC = ({ sprint, selectSprint, workspaceSlug, projectId, openIssueModal, addIssueToSprint, }) => { const router = useRouter(); const { data: sprintIssues } = useSWR(CYCLE_ISSUES(sprint.id), () => cycleServices.getCycleIssues(workspaceSlug, projectId, sprint.id) ); const { data: projectIssues } = useSWR( projectId && workspaceSlug ? PROJECT_ISSUES_LIST(workspaceSlug, projectId) : null, workspaceSlug ? () => issuesServices.getIssues(workspaceSlug, projectId) : null ); return (
{({ open }) => (

{sprint.name}

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

{sprintIssues ? ( sprintIssues.length > 0 ? ( sprintIssues.map((issue) => (
{issue.issue_details.state_detail.name}
)) ) : (

This sprint has no issues.

) ) : (
)}

Add Existing Issue

{projectIssues?.results.map((issue) => ( { addIssueToSprint(sprint.id, issue.id); }} > {({ active }) => (

{issue.name}

)}
))}
)}
); }; export default SprintView;