import { useQuery } from "@tanstack/react-query";

import { client } from "@/lib/rpc";

interface UseGetBoardsProps {
  projectId: string;
}

export const useGetBoards = ({ projectId }: UseGetBoardsProps) => {
  const query = useQuery({
    queryKey: ["boards", projectId],
    queryFn: async () => {
      const response = await client.api.boards.$get({
        query: { projectId },
      });

      if (!response.ok) {
        throw new Error("Failed to fetch boards");
      }

      const { data } = await response.json();
      return data;
    },
  });

  return query;
}; 