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

import { eventsQueryKeys } from '../events-query-keys';
import { eventsApi, type PostGetMorePhotosReturn } from '../events-api';

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

export const useGetMorePhotosQuery = (
  token: string,
  event_id: number,
  last_id: number,
  enabled: boolean
) => {
  return useQuery<PostGetMorePhotosReturn, BaseAxiosError>({
    queryKey: eventsQueryKeys.getMorePhotos(token, event_id, last_id),
    queryFn: async () => {
      const response = await eventsApi.getMorePhotos(token, event_id, last_id);
      return response.data;
    },
    enabled
  });
};
