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

interface UseGetProjectLabelsProps {
  projectId: string;
}

export const useGetProjectLabels = ({ projectId }: UseGetProjectLabelsProps) => {
  const query = useQuery({
    queryKey: ["project-labels", projectId],
    queryFn: async () => {
      const response = await client.api.projects[":projectId"]["labels"].$get({
        param: { projectId },
      });

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

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

  return query;
}; 