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

import { rankingQueryKeys } from '../ranking-query-keys';
import { type PostGetCountriesRanking, rankingApi } from '../ranking-api';

import type { BaseAxiosError } from '../../../../types';

export const usePostGetCountriesRanking = () => {
  return useQuery<PostGetCountriesRanking, BaseAxiosError>({
    queryKey: rankingQueryKeys.getCountriesRanking(),
    queryFn: async () => {
      const response = await rankingApi.getCountriesRanking();
      return response.data;
    }
  });
};
