Use api client for auto complete

This commit is contained in:
Rene Pfeuffer
2019-11-21 13:06:22 +01:00
parent c81e78998e
commit 9cf55b8335
3 changed files with 9 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import React from "react";
import { SelectValue, AutocompleteObject } from "@scm-manager/ui-types";
import Autocomplete from "./Autocomplete";
import { apiClient } from "./apiclient";
export type AutocompleteProps = {
autocompleteLink?: string;
@@ -19,7 +20,8 @@ export default class UserGroupAutocomplete extends React.Component<Props> {
loadSuggestions = (inputValue: string): Promise<SelectValue[]> => {
const url = this.props.autocompleteLink;
const link = url + "?q=";
return fetch(link + inputValue)
return apiClient
.get(link + inputValue)
.then(response => response.json())
.then((json: AutocompleteObject[]) => {
return json.map(element => {

View File

@@ -7,6 +7,7 @@ import { Page } from "@scm-manager/ui-components";
import { getGroupsLink, getUserAutoCompleteLink } from "../../modules/indexResource";
import { createGroup, isCreateGroupPending, getCreateGroupFailure, createGroupReset } from "../modules/groups";
import GroupForm from "../components/GroupForm";
import { apiClient } from "@scm-manager/ui-components/src";
type Props = WithTranslation & {
createGroup: (link: string, group: Group, callback?: () => void) => void;
@@ -40,7 +41,8 @@ class CreateGroup extends React.Component<Props> {
loadUserAutocompletion = (inputValue: string) => {
const url = this.props.autocompleteLink + "?q=";
return fetch(url + inputValue)
return apiClient
.get(url + inputValue)
.then(response => response.json())
.then(json => {
return json.map(element => {

View File

@@ -8,6 +8,7 @@ import { Group } from "@scm-manager/ui-types";
import { ErrorNotification } from "@scm-manager/ui-components";
import { getUserAutoCompleteLink } from "../../modules/indexResource";
import DeleteGroup from "./DeleteGroup";
import { apiClient } from "@scm-manager/ui-components/src";
type Props = {
group: Group;
@@ -36,7 +37,8 @@ class EditGroup extends React.Component<Props> {
loadUserAutocompletion = (inputValue: string) => {
const url = this.props.autocompleteLink + "?q=";
return fetch(url + inputValue)
return apiClient
.get(url + inputValue)
.then(response => response.json())
.then(json => {
return json.map(element => {