/* 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 type { ProjectMember } from '../schemas/ProjectMember';
import { fetcher, FetcherOptions } from 'services/fetcher';

export type SendInvitationRequestBody = {
  projectID: string;
  role: 'Executor' | 'Owner' | 'Viewer';
  userID: string;
};

export type SendInvitationOkResponse = {
  data?: ProjectMember;
};

export type SendInvitationErrorResponse = unknown;

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

export function sendInvitation(props: SendInvitationProps): Promise<SendInvitationOkResponse> {
  return fetcher<SendInvitationOkResponse, unknown, SendInvitationRequestBody>({
    url: `/auth/send_invitation`,
    method: 'POST',
    ...props
  });
}

export type SendInvitationMutationProps<T extends keyof SendInvitationProps> = Omit<SendInvitationProps, T> &
  Partial<Pick<SendInvitationProps, T>>;

/**
 * This API is used to send project invite to an user
 */
export function useSendInvitationMutation<T extends keyof SendInvitationProps>(
  props: Pick<Partial<SendInvitationProps>, T>,
  options?: Omit<
    UseMutationOptions<SendInvitationOkResponse, SendInvitationErrorResponse, SendInvitationMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<SendInvitationOkResponse, SendInvitationErrorResponse, SendInvitationMutationProps<T>>(
    (mutateProps: SendInvitationMutationProps<T>) =>
      sendInvitation({ ...props, ...mutateProps } as SendInvitationProps),
    options
  );
}
