/* 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 UpdateProjectNameRequestBody = {
  projectID: string;
  projectName: string;
};

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

export type UpdateProjectNameErrorResponse = unknown;

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

export function updateProjectName(props: UpdateProjectNameProps): Promise<UpdateProjectNameOkResponse> {
  return fetcher<UpdateProjectNameOkResponse, unknown, UpdateProjectNameRequestBody>({
    url: `/auth/update_project_name`,
    method: 'POST',
    ...props
  });
}

export type UpdateProjectNameMutationProps<T extends keyof UpdateProjectNameProps> = Omit<UpdateProjectNameProps, T> &
  Partial<Pick<UpdateProjectNameProps, T>>;

/**
 * This API is used to update a project name
 */
export function useUpdateProjectNameMutation<T extends keyof UpdateProjectNameProps>(
  props: Pick<Partial<UpdateProjectNameProps>, T>,
  options?: Omit<
    UseMutationOptions<UpdateProjectNameOkResponse, UpdateProjectNameErrorResponse, UpdateProjectNameMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<UpdateProjectNameOkResponse, UpdateProjectNameErrorResponse, UpdateProjectNameMutationProps<T>>(
    (mutateProps: UpdateProjectNameMutationProps<T>) =>
      updateProjectName({ ...props, ...mutateProps } as UpdateProjectNameProps),
    options
  );
}
