Web: Common: PeopleSelector: added the ability to send a list of groups to PeopleSelector without calling api

This commit is contained in:
Artem Tarasov 2021-02-04 17:32:28 +03:00
parent 1121559cda
commit b2ee7251b7

View File

@ -23,11 +23,14 @@ class PeopleSelector extends React.Component {
} }
componentDidMount() { componentDidMount() {
const { groupsCaption } = this.props; const { groupsCaption, groupList } = this.props;
changeLanguage(i18n).then((t) =>
changeLanguage(i18n).then((t) => {
if (!groupList) {
getGroupList(this.props.useFake) getGroupList(this.props.useFake)
.then((groups) => .then((groups) =>
this.setState({ this.setState(
{
groups: [ groups: [
{ {
key: "all", key: "all",
@ -35,10 +38,23 @@ class PeopleSelector extends React.Component {
total: 0, total: 0,
}, },
].concat(this.convertGroups(groups)), ].concat(this.convertGroups(groups)),
}) },
() => console.log(this.state.groups, groups, this.props.groupsArr)
) )
.catch((error) => console.log(error)) )
); .catch((error) => console.log(error));
} else {
this.setState({
groups: [
{
key: "all",
label: t("CustomAllGroups", { groupsCaption }),
total: 0,
},
].concat(groupList),
});
}
});
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
@ -227,6 +243,8 @@ class PeopleSelector extends React.Component {
showCounter, showCounter,
} = this.props; } = this.props;
console.log("render group");
return ( return (
<AdvancedSelector <AdvancedSelector
id={id} id={id}