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 useGetNmRegionDataQuery = (id: number, enabled: boolean, token?: string) => {
  return useQuery<PostGetRegionDataReturn, BaseAxiosError>({
    queryKey: regionQueryKeys.getNmRegionData(id, token),
    queryFn: async () => {
      const response = await regionsApi.getNmRegionData(id, token);
      return response.data;
    },
    enabled
  });
};
