// react import React, { useEffect, useState } from "react"; // next import { useRouter } from "next/router"; import type { NextPage } from "next"; import Link from "next/link"; // swr import useSWR from "swr"; // services import issuesServices from "lib/services/issues.service"; import sprintService from "lib/services/cycles.service"; // hooks import useUser from "lib/hooks/useUser"; import useIssuesProperties from "lib/hooks/useIssuesProperties"; // fetching keys import { CYCLE_LIST } from "constants/fetch-keys"; // hoc import withAuth from "lib/hoc/withAuthWrapper"; // layouts import AppLayout from "layouts/app-layout"; // components import CycleIssuesListModal from "components/project/cycles/CycleIssuesListModal"; import ConfirmIssueDeletion from "components/project/issues/confirm-issue-deletion"; import ConfirmSprintDeletion from "components/project/cycles/ConfirmCycleDeletion"; import CreateUpdateIssuesModal from "components/project/issues/CreateUpdateIssueModal"; import CreateUpdateSprintsModal from "components/project/cycles/CreateUpdateCyclesModal"; // headless ui import { Popover, Transition } from "@headlessui/react"; // ui import { BreadcrumbItem, Breadcrumbs, HeaderButton, Spinner, EmptySpace, EmptySpaceItem } from "ui"; // icons import { ArrowPathIcon, ChevronDownIcon, PlusIcon } from "@heroicons/react/24/outline"; // types import { IIssue, ICycle, SelectSprintType, SelectIssue, Properties } from "types"; // constants import { classNames, replaceUnderscoreIfSnakeCase } from "constants/common"; const ProjectSprints: NextPage = () => { const [isOpen, setIsOpen] = useState(false); const [selectedSprint, setSelectedSprint] = useState(); const [isIssueModalOpen, setIsIssueModalOpen] = useState(false); const [selectedIssues, setSelectedIssues] = useState(); const [deleteIssue, setDeleteIssue] = useState(); const [cycleIssuesListModal, setCycleIssuesListModal] = useState(false); const [cycleId, setCycleId] = useState(""); const { activeWorkspace, activeProject, issues } = useUser(); const router = useRouter(); const { projectId } = router.query; const { data: cycles } = useSWR( activeWorkspace && projectId ? CYCLE_LIST(projectId as string) : null, activeWorkspace && projectId ? () => sprintService.getCycles(activeWorkspace.slug, projectId as string) : null ); const [properties, setProperties] = useIssuesProperties( activeWorkspace?.slug, projectId as string ); const openCreateIssueModal = ( cycleId: string, issue?: IIssue, actionType: "create" | "edit" | "delete" = "create" ) => { const cycle = cycles?.find((cycle) => cycle.id === cycleId); if (cycle) { setSelectedSprint({ ...cycle, actionType: "create-issue", }); if (issue) setSelectedIssues({ ...issue, actionType }); setIsIssueModalOpen(true); } }; const openIssuesListModal = (cycleId: string) => { setCycleId(cycleId); setCycleIssuesListModal(true); }; useEffect(() => { if (isOpen) return; const timer = setTimeout(() => { setSelectedSprint(undefined); clearTimeout(timer); }, 500); }, [isOpen]); useEffect(() => { if (selectedIssues?.actionType === "delete") { setDeleteIssue(selectedIssues.id); } }, [selectedIssues]); return ( } right={
{({ open }) => ( <> View

Properties

{Object.keys(properties).map((key) => ( ))}
)}
setIsOpen(true)} />
} > setDeleteIssue(undefined)} isOpen={!!deleteIssue} data={selectedIssues} /> setCycleIssuesListModal(false)} issues={issues} cycleId={cycleId} /> {cycles ? ( cycles.length > 0 ? (
{cycles.map((cycle) => ( {cycle.name} ))}
) : (
Use
Ctrl/Command + Q
{" "} shortcut to create a new cycle } Icon={PlusIcon} action={() => setIsOpen(true)} />
) ) : (
)}
); }; export default withAuth(ProjectSprints);