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

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

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

export const useGetRegionDareQuery = (megaregion: number, token: string, enabled: boolean) => {
  return useQuery<PostGetRegionsDAREReturn, BaseAxiosError>({
    queryKey: dareQueryKeys.getRegionsDare(megaregion, token),
    queryFn: async () => {
      const response = await dareApi.getRegionsDare(megaregion, token);
      return response.data;
    },
    enabled
  });
};
