plane/web/components/cycles/cycles-list/all-cycles-list.tsx

30 lines
840 B
TypeScript
Raw Normal View History

2023-05-28 20:44:40 +00:00
import { useRouter } from "next/router";
import useSWR from "swr";
// services
import cyclesService from "services/cycles.service";
// components
import { CyclesView } from "components/cycles";
// fetch-keys
2023-05-28 21:08:16 +00:00
import { CYCLES_LIST } from "constants/fetch-keys";
2023-05-28 20:44:40 +00:00
type Props = {
viewType: string | null;
};
export const AllCyclesList: React.FC<Props> = ({ viewType }) => {
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
const { data: allCyclesList, mutate } = useSWR(
2023-05-28 21:08:16 +00:00
workspaceSlug && projectId ? CYCLES_LIST(projectId.toString()) : null,
2023-05-28 20:44:40 +00:00
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), "all")
2023-05-28 20:44:40 +00:00
: null
);
return <CyclesView cycles={allCyclesList} mutateCycles={mutate} viewType={viewType} />;
2023-05-28 20:44:40 +00:00
};