import { FC } from "react"; import useSWR from "swr"; import { observer } from "mobx-react-lite"; // store import { useMobxStore } from "lib/mobx/store-provider"; // components import { CyclesBoard, CyclesList, CyclesListGanttChartView } from "components/cycles"; // ui components import { Loader } from "components/ui"; // types import { TCycleLayout } from "types"; export interface ICyclesView { filter: "all" | "current" | "upcoming" | "draft" | "completed" | "incomplete"; layout: TCycleLayout; workspaceSlug: string; projectId: string; peekCycle: string; } export const CyclesView: FC = observer((props) => { const { filter, layout, workspaceSlug, projectId, peekCycle } = props; // store const { cycle: cycleStore } = useMobxStore(); // api call to fetch cycles list const { isLoading } = useSWR( workspaceSlug && projectId && filter ? `CYCLES_LIST_${projectId}_${filter}` : null, workspaceSlug && projectId && filter ? () => cycleStore.fetchCycles(workspaceSlug, projectId, filter) : null ); const cyclesList = cycleStore.cycles?.[projectId]; return ( <> {layout === "list" && ( <> {!isLoading ? ( ) : ( )} )} {layout === "board" && ( <> {!isLoading ? ( ) : ( )} )} {layout === "gantt" && ( <> {!isLoading ? ( ) : ( )} )} ); });