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 usePostGetVisitedSeriesIdsQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetVisitedIds, BaseAxiosError>({
    queryKey: mapsQueryKeys.getVisitedSeriesIds(token),
    queryFn: async () => {
      const response = await mapsApi.getVisitedSeriesIds(token);
      return response.data;
    },
    enabled
  });
};
