/* 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 UpdateStateRequestBody = {
  isDeactivate: boolean;
  username: string;
};

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

export type UpdateStateErrorResponse = unknown;

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

export function updateState(props: UpdateStateProps): Promise<UpdateStateOkResponse> {
  return fetcher<UpdateStateOkResponse, unknown, UpdateStateRequestBody>({
    url: `/auth/update/state`,
    method: 'POST',
    ...props
  });
}

export type UpdateStateMutationProps<T extends keyof UpdateStateProps> = Omit<UpdateStateProps, T> &
  Partial<Pick<UpdateStateProps, T>>;

/**
 * This API is used to update the state of a user.
 */
export function useUpdateStateMutation<T extends keyof UpdateStateProps>(
  props: Pick<Partial<UpdateStateProps>, T>,
  options?: Omit<
    UseMutationOptions<UpdateStateOkResponse, UpdateStateErrorResponse, UpdateStateMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<UpdateStateOkResponse, UpdateStateErrorResponse, UpdateStateMutationProps<T>>(
    (mutateProps: UpdateStateMutationProps<T>) => updateState({ ...props, ...mutateProps } as UpdateStateProps),
    options
  );
}
