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

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

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

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