/* 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 ResetPasswordRequestBody = {
  newPassword: string;
  oldPassword: string;
  username: string;
};

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

export type ResetPasswordErrorResponse = unknown;

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

export function resetPassword(props: ResetPasswordProps): Promise<ResetPasswordOkResponse> {
  return fetcher<ResetPasswordOkResponse, unknown, ResetPasswordRequestBody>({
    url: `/auth/reset/password`,
    method: 'POST',
    ...props
  });
}

export type ResetPasswordMutationProps<T extends keyof ResetPasswordProps> = Omit<ResetPasswordProps, T> &
  Partial<Pick<ResetPasswordProps, T>>;

/**
 * This API is used to reset the password of a user.
 */
export function useResetPasswordMutation<T extends keyof ResetPasswordProps>(
  props: Pick<Partial<ResetPasswordProps>, T>,
  options?: Omit<
    UseMutationOptions<ResetPasswordOkResponse, ResetPasswordErrorResponse, ResetPasswordMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<ResetPasswordOkResponse, ResetPasswordErrorResponse, ResetPasswordMutationProps<T>>(
    (mutateProps: ResetPasswordMutationProps<T>) => resetPassword({ ...props, ...mutateProps } as ResetPasswordProps),
    options
  );
}
