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, enabled: boolean) => {
  return useQuery<PostGetSlowReturn, BaseAxiosError>({
    queryKey: countriesQueryKeys.getSlow(token),
    queryFn: async () => {
      const response = await countriesApi.getSlow(token);
      return response.data;
    },
    enabled
  });
};
