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

import { regionsQueryKeys } from '../regions-query-keys';
import { regionsApi, type PostGetMegaReturn } from '../regions-api';

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

export const useGetMegaregionsQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetMegaReturn, BaseAxiosError>({
    queryKey: regionsQueryKeys.getMegaregions(token),
    queryFn: async () => {
      const response = await regionsApi.getMegaregions(token);
      return response.data;
    }
  });
};
