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

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

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

export const useGetDareRegionDataQuery = (id: number, enabled: boolean, token?: string) => {
  return useQuery<PostGetRegionDataReturn, BaseAxiosError>({
    queryKey: regionQueryKeys.getDareRegionData(id, token),
    queryFn: async () => {
      const response = await regionsApi.getDareRegionData(id, token);
      return response.data;
    },
    enabled
  });
};
