diff --git a/frontend/src/component/project/access-add-user.js b/frontend/src/component/project/access-add-user.js index 9ab9b932ea..3e6c843c77 100644 --- a/frontend/src/component/project/access-add-user.js +++ b/frontend/src/component/project/access-add-user.js @@ -1,4 +1,5 @@ import React, { useEffect, useState } from 'react'; +import projectApi from '../../store/project/api'; import PropTypes from 'prop-types'; import { Select, @@ -32,8 +33,7 @@ function AddUserComponent({ roles, addUserToRole }) { if (q.length > 1) { setLoading(true); // TODO: Do not hard-code fetch here. - const response = await fetch(`api/admin/user-admin/search?q=${q}`); - const users = await response.json(); + const users = await projectApi.searchProjectUser(q); setOptions([...users]); } else { setOptions([]); diff --git a/frontend/src/store/project/api.js b/frontend/src/store/project/api.js index ec0aa6653f..f8178ffcec 100644 --- a/frontend/src/store/project/api.js +++ b/frontend/src/store/project/api.js @@ -66,6 +66,10 @@ function validate(id) { }).then(throwIfNotSuccess); } +function searchProjectUser(query) { + return fetch(`${formatApiPath('api/admin/user-admin/search')}?q=${query}`).then(res => res.json()) +} + export default { fetchAll, create, @@ -75,4 +79,5 @@ export default { fetchAccess, addUserToRole, removeUserFromRole, + searchProjectUser, };