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

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

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

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