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

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

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

export const usePostGetLastMapUpdateDateQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetLastMapUpdateDate, BaseAxiosError>({
    queryKey: mapsQueryKeys.getLastMapUpdateDate(token),
    queryFn: async () => {
      const response = await mapsApi.getLastMapUpdateDate(token);
      return response.data;
    },
    enabled
  });
};
