mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +00:00
Handle search user (frontend)
This commit is contained in:
parent
baee801941
commit
5cf7c45202
@ -91,7 +91,7 @@ class InputSearch extends React.Component { // eslint-disable-line react/prefer-
|
||||
<ul>
|
||||
{map(this.state.filteredUsers, (user) => (
|
||||
<InputSearchLi
|
||||
key={user.name}
|
||||
key={user.id || user._id}
|
||||
item={user}
|
||||
isAdding={this.state.isAdding}
|
||||
onClick={this.handleClick}
|
||||
|
||||
@ -15,7 +15,7 @@ function InputSearchLi({ onClick, isAdding, item }) {
|
||||
<li className={styles.li}>
|
||||
<div>
|
||||
<div>
|
||||
{item.name}
|
||||
{item.username}
|
||||
</div>
|
||||
<div onClick={() => onClick(item)}>
|
||||
<i className={`fa ${icon}`} />
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { LOCATION_CHANGE } from 'react-router-redux';
|
||||
import { includes, toLower } from 'lodash';
|
||||
import {
|
||||
call,
|
||||
cancel,
|
||||
@ -33,32 +32,9 @@ import {
|
||||
|
||||
export function* fetchUser(action) {
|
||||
try {
|
||||
const fakeUser = [
|
||||
{
|
||||
id: '11',
|
||||
name: 'John Lennon',
|
||||
},
|
||||
{
|
||||
id: '12',
|
||||
name: 'Paul McCartney',
|
||||
},
|
||||
{
|
||||
id: '13',
|
||||
name: 'George Harrison',
|
||||
},
|
||||
{
|
||||
id: '14',
|
||||
name: 'Ringo Starr',
|
||||
},
|
||||
];
|
||||
// Temporary waiting for backend dynamic
|
||||
const filteredUsers = fakeUser.filter((user) => {
|
||||
if (includes(toLower(user.name), toLower(action.user))) {
|
||||
return user;
|
||||
}
|
||||
});
|
||||
const data = yield call(request, `/users-permissions/search/${action.user}`, { method: 'GET' });
|
||||
|
||||
yield put(getUserSucceeded(filteredUsers));
|
||||
yield put(getUserSucceeded(data));
|
||||
} catch(error) {
|
||||
strapi.notification.error('users-permissions.notification.error.fetchUser');
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user