Max - Add filter by department in staff members [skip ci]
This commit is contained in:
parent
c2ab1f9b6e
commit
80f4281ab1
|
@ -1,4 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
import i18n from 'lib-app/i18n';
|
import i18n from 'lib-app/i18n';
|
||||||
import API from 'lib-app/api-call';
|
import API from 'lib-app/api-call';
|
||||||
|
@ -13,14 +14,6 @@ import Loading from 'core-components/loading';
|
||||||
|
|
||||||
class AdminPanelStaffMembers extends React.Component {
|
class AdminPanelStaffMembers extends React.Component {
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
departments: React.PropTypes.array
|
|
||||||
};
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
departments: []
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
selectedDepartment: 0,
|
selectedDepartment: 0,
|
||||||
staffList: [],
|
staffList: [],
|
||||||
|
@ -35,6 +28,7 @@ class AdminPanelStaffMembers extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
console.log(this.state.staffList);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Header title={i18n('STAFF_MEMBERS')} description={i18n('STAFF_MEMBERS_DESCRIPTION')} />
|
<Header title={i18n('STAFF_MEMBERS')} description={i18n('STAFF_MEMBERS_DESCRIPTION')} />
|
||||||
|
@ -42,7 +36,7 @@ class AdminPanelStaffMembers extends React.Component {
|
||||||
<Button size="medium" onClick={() => {}} type="secondary" className="">
|
<Button size="medium" onClick={() => {}} type="secondary" className="">
|
||||||
<Icon name="user-plus" className=""/> {i18n('ADD_NEW_STAFF')}
|
<Icon name="user-plus" className=""/> {i18n('ADD_NEW_STAFF')}
|
||||||
</Button>
|
</Button>
|
||||||
{(this.state.loading) ? <Loading backgrounded /> : <PeopleList list={this.state.staffList} />}
|
{(this.state.loading) ? <Loading backgrounded /> : <PeopleList list={this.getStaffList()} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,14 +45,25 @@ class AdminPanelStaffMembers extends React.Component {
|
||||||
return {
|
return {
|
||||||
items: this.getDepartments(),
|
items: this.getDepartments(),
|
||||||
onChange: (event) => {
|
onChange: (event) => {
|
||||||
|
let departments = SessionStore.getDepartments();
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedDepartment: event.index && this.props.departments[event.index - 1].id
|
selectedDepartment: event.index && departments[event.index - 1].id
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
size: 'medium'
|
size: 'medium'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStaffList() {
|
||||||
|
if(!this.state.selectedDepartment) {
|
||||||
|
return this.state.staffList;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _.filter(this.state.staffList, (o) => {
|
||||||
|
return _.findIndex(o.departments, {id: this.state.selectedDepartment}) !== -1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getDepartments() {
|
getDepartments() {
|
||||||
let departments = SessionStore.getDepartments().map((department) => {
|
let departments = SessionStore.getDepartments().map((department) => {
|
||||||
return {content: department.name};
|
return {content: department.name};
|
||||||
|
|
Loading…
Reference in New Issue