import { useQuery } from '@tanstack/react-query';
import { useInject } from '@/lib/di/hooks/useInject';
import { LEAGUE_STEWARDING_SERVICE_TOKEN } from '@/lib/di/tokens';
import { enhanceQueryResult } from '@/lib/di/hooks/useReactQueryWithApiError';

export function useLeagueStewardingData(leagueId: string) {
  const leagueStewardingService = useInject(LEAGUE_STEWARDING_SERVICE_TOKEN);

  const queryResult = useQuery({
    queryKey: ['leagueStewardingData', leagueId],
    queryFn: () => leagueStewardingService.getLeagueStewardingData(leagueId),
    enabled: !!leagueId,
  });

  return enhanceQueryResult(queryResult);
}
