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

import { dareQueryKeys } from '../dare-query-keys';
import { dareApi, type PostGetMegaReturn } from '../dare-api';

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

export const useGetMegaregionsDareQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetMegaReturn, BaseAxiosError>({
    queryKey: dareQueryKeys.getMegaregionsDare(token),
    queryFn: async () => {
      const response = await dareApi.getMegaregionsDare(token);
      return response.data;
    },
    enabled
  });
};
