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

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

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

export const usePostCancelEventMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    { token: string; event_id: number },
    ResponseType
  >({
    mutationKey: eventsQueryKeys.cancelEvent(),
    mutationFn: async (data) => {
      const response = await eventsApi.cancelEvent(data.token, data.event_id);
      return response.data;
    }
  });
};
