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

import { IssuesService } from '@/client/services/IssuesService';

export function useRepoLabels(workspaceName: string | null, repoName: string | null) {
  return useQuery({
    queryKey: ['repo', workspaceName, repoName, 'labels'],
    queryFn: () => {
      if (!workspaceName || !repoName) throw new Error('Missing params');
      return IssuesService.issueListLabels({ workspaceName, repoName }).then((r) => r.data);
    },
    enabled: !!workspaceName && !!repoName,
  });
}
