feat: status updating on the server and statuses fetching

This commit is contained in:
2025-08-04 18:49:27 +04:00
parent 24de9f5446
commit c98a5cc811
9 changed files with 277 additions and 26 deletions

View File

@ -0,0 +1,29 @@
import { useEffect, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { StatusSchema } from "@/client";
import { getStatusesOptions } from "@/client/@tanstack/react-query.gen";
type Props = {
boardId?: number;
};
const useStatusesList = ({ boardId }: Props) => {
const [statuses, setStatuses] = useState<StatusSchema[]>([]);
const { data, refetch, isLoading } = useQuery({
...getStatusesOptions({ path: { boardId: boardId! } }),
enabled: boardId !== undefined,
});
useEffect(() => {
if (boardId === undefined) {
setStatuses([]);
} else if (data?.statuses) {
setStatuses(data.statuses);
}
}, [data?.statuses, boardId]);
return { statuses, setStatuses, refetch, isLoading };
};
export default useStatusesList;