// react import React, { useEffect, useState } from "react"; // next import { useRouter } from "next/router"; import type { NextPage } from "next"; // swr import useSWR from "swr"; // hoc import withAuth from "lib/hoc/withAuthWrapper"; // services import sprintService from "lib/services/cycles.service"; // hooks import useUser from "lib/hooks/useUser"; // layouts import AppLayout from "layouts/app-layout"; // components import CreateUpdateCycleModal from "components/project/cycles/create-update-cycle-modal"; import CycleStatsView from "components/project/cycles/stats-view"; // ui import { BreadcrumbItem, Breadcrumbs, HeaderButton, Spinner, EmptySpace, EmptySpaceItem } from "ui"; // icons import { ArrowPathIcon, PlusIcon } from "@heroicons/react/24/outline"; // types import { ICycle, SelectSprintType } from "types"; // fetching keys import { CYCLE_LIST } from "constants/fetch-keys"; const ProjectSprints: NextPage = () => { const [selectedCycle, setSelectedCycle] = useState(); const [createUpdateCycleModal, setCreateUpdateCycleModal] = useState(false); const { activeWorkspace, activeProject } = 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 ); useEffect(() => { if (createUpdateCycleModal) return; const timer = setTimeout(() => { setSelectedCycle(undefined); clearTimeout(timer); }, 500); }, [createUpdateCycleModal]); return ( } right={ { const e = new KeyboardEvent("keydown", { ctrlKey: true, key: "q", }); document.dispatchEvent(e); }} /> } > {cycles ? ( cycles.length > 0 ? (
) : (
Use
Ctrl/Command + Q
{" "} shortcut to create a new cycle } Icon={PlusIcon} action={() => setCreateUpdateCycleModal(true)} />
) ) : (
)}
); }; export default withAuth(ProjectSprints);