mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 12:36:39 -04:00
47 lines
1 KiB
React
47 lines
1 KiB
React
![]() |
import React, { PureComponent } from 'react';
|
||
|
import AdminUsersList from './AdminUsersList.jsx';
|
||
|
|
||
|
// see: http://stackoverflow.com/questions/1909441/jquery-keyup-delay
|
||
|
const delay = (function(){
|
||
|
var timer = 0;
|
||
|
return function(callback, ms){
|
||
|
clearTimeout (timer);
|
||
|
timer = setTimeout(callback, ms);
|
||
|
};
|
||
|
})();
|
||
|
|
||
|
export default class AdminUsers extends PureComponent {
|
||
|
|
||
|
constructor() {
|
||
|
super();
|
||
|
this.updateQuery = this.updateQuery.bind(this);
|
||
|
this.state = {
|
||
|
value: '',
|
||
|
query: ''
|
||
|
}
|
||
|
}
|
||
|
|
||
|
updateQuery(e) {
|
||
|
e.persist()
|
||
|
e.preventDefault();
|
||
|
this.setState({
|
||
|
value: e.target.value
|
||
|
});
|
||
|
delay(() => {
|
||
|
this.setState({
|
||
|
query: e.target.value
|
||
|
});
|
||
|
}, 700 );
|
||
|
}
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<div className="admin-users">
|
||
|
<input className="admin-users-search" placeholder="Search…" type="text" name="adminUsersQuery" value={this.state.value} onChange={this.updateQuery} />
|
||
|
<AdminUsersList terms={{query: this.state.query}} />
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
|