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

import { mapsQueryKeys } from '../maps-query-keys';
import { mapsApi, type PostGetVisitedIds } from '../maps-api';

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

export const usePostGetVisitedRegionsIdsQuery = (
  token: string,
  type: 'in' | 'by',
  year: number,
  uid: number,
  enabled: boolean
) => {
  return useQuery<PostGetVisitedIds, BaseAxiosError>({
    queryKey: mapsQueryKeys.getVisitedRegionsIds(token, type, year, uid),
    queryFn: async () => {
      const response = await mapsApi.getVisitedRegionsIds(token, type, year, uid);
      return response.data;
    },
    enabled
  });
};
