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

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

interface UseGetBoardProps {
  boardId: string;
}

export const useGetBoard = ({ boardId }: UseGetBoardProps) => {
  const query = useQuery({
    queryKey: ["board", boardId],
    queryFn: async () => {
      const response = await client.api.boards[":boardId"].$get({
        param: { boardId },
      });

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

      const { data } = await response.json();
      return data;
    },
    enabled: !!boardId,
  });

  return query;
}; 