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 usePostSharedTripRemoveParticipantMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    { token: string; event_id: number; user_id: number },
    ResponseType
  >({
    mutationKey: eventsQueryKeys.sharedTripRemoveParticipant(),
    mutationFn: async (variables) => {
      const response = await eventsApi.sharedTripRemoveParticipant(
        variables.token,
        variables.event_id,
        variables.user_id
      );
      return response.data;
    }
  });
};
