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

export interface IUseRemoveMutationOptions<
  TUseRemoveMutationData,
  _TUseRemoveMutationError,
  TUseRemoveMutationVariables
> {
  mutationFn: (variables: TUseRemoveMutationVariables) => Promise<TUseRemoveMutationData>;
}

export function useRemove<
  TUseRemoveMutationData,
  TUseRemoveMutationError,
  TUseRemoveMutationVariables
>(
  options: IUseRemoveMutationOptions<
    TUseRemoveMutationData,
    TUseRemoveMutationError,
    TUseRemoveMutationVariables
  >
) {
  const { mutationFn, ...params } = options;

  return useMutation<TUseRemoveMutationData, TUseRemoveMutationError, TUseRemoveMutationVariables>({
    mutationFn,
    ...params,
  });
}
