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

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

import type { BaseAxiosError } from '../../../../types';
import { ResponseType } from '@api/response-type';

export const usePostUpdateEventMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, PostUpdateEvent, ResponseType>({
    mutationKey: eventsQueryKeys.updateEvent(),
    mutationFn: async (data) => {
      const response = await eventsApi.updateEvent(data);
      return response.data;
    }
  });
};
