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

interface UseGetWorkspaceLabelsProps {
  workspaceId: string;
}

export const useGetWorkspaceLabels = ({ workspaceId }: UseGetWorkspaceLabelsProps) => {
  const query = useQuery({
    queryKey: ["workspace-labels", workspaceId],
    queryFn: async () => {
      const response = await client.api.workspaces[":workspaceId"]["labels"].$get({
        param: { workspaceId },
      });

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

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

  return query;
}; 