/* eslint-disable */
// This code is autogenerated using @harnessio/oats-cli.
// Please do not modify this code directly.
import { useMutation, UseMutationOptions } from '@tanstack/react-query';

import { fetcher, FetcherOptions } from 'services/fetcher';

export type AcceptInvitationRequestBody = {
  projectID: string;
  userID: string;
};

export type AcceptInvitationOkResponse = {
  message?: string;
};

export type AcceptInvitationErrorResponse = unknown;

export interface AcceptInvitationProps extends Omit<FetcherOptions<unknown, AcceptInvitationRequestBody>, 'url'> {
  body: AcceptInvitationRequestBody;
}

export function acceptInvitation(props: AcceptInvitationProps): Promise<AcceptInvitationOkResponse> {
  return fetcher<AcceptInvitationOkResponse, unknown, AcceptInvitationRequestBody>({
    url: `/auth/accept_invitation`,
    method: 'POST',
    ...props
  });
}

export type AcceptInvitationMutationProps<T extends keyof AcceptInvitationProps> = Omit<AcceptInvitationProps, T> &
  Partial<Pick<AcceptInvitationProps, T>>;

/**
 * This API is used to accept a project invite
 */
export function useAcceptInvitationMutation<T extends keyof AcceptInvitationProps>(
  props: Pick<Partial<AcceptInvitationProps>, T>,
  options?: Omit<
    UseMutationOptions<AcceptInvitationOkResponse, AcceptInvitationErrorResponse, AcceptInvitationMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<AcceptInvitationOkResponse, AcceptInvitationErrorResponse, AcceptInvitationMutationProps<T>>(
    (mutateProps: AcceptInvitationMutationProps<T>) =>
      acceptInvitation({ ...props, ...mutateProps } as AcceptInvitationProps),
    options
  );
}
