feat: boards with statuses fetch

This commit is contained in:
2025-08-03 13:40:09 +04:00
parent 624c94155c
commit 5435750fb5
21 changed files with 265 additions and 106 deletions

View File

@ -0,0 +1,29 @@
import { useEffect, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { BoardSchema } from "@/client";
import { getBoardsOptions } from "@/client/@tanstack/react-query.gen";
type Props = {
projectId?: number;
};
const useBoardsList = ({ projectId }: Props) => {
const [boards, setBoards] = useState<BoardSchema[]>([]);
const { data, refetch, isLoading } = useQuery({
...getBoardsOptions({ path: { project_id: projectId! } }),
enabled: projectId !== undefined,
});
useEffect(() => {
if (projectId === undefined) {
setBoards([]);
} else if (data?.boards) {
setBoards(data.boards);
}
}, [data?.boards, projectId]);
return { boards, setBoards, refetch, isLoading };
};
export default useBoardsList;