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

import { countriesQueryKeys } from '../countries-query-keys';
import { countriesApi, type PostGetSlowReturn } from '../countries-api';

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

export const useGetSlowQuery = (token: string) => {
  return useQuery<PostGetSlowReturn, BaseAxiosError>({
    queryKey: countriesQueryKeys.getSlow(token),
    queryFn: async () => {
      const response = await countriesApi.getSlow(token);
      return response.data;
    }
  });
};
