Refactor out Setting.getArrayItem()

This commit is contained in:
Yang Luo
2021-07-09 23:05:50 +08:00
parent 3923574d57
commit 1bfddc5d53
3 changed files with 8 additions and 2 deletions

View File

@ -87,7 +87,8 @@ class AffiliationSelect extends React.Component {
) : (
<Select virtual={false} style={{width: '100%'}} value={this.props.user.affiliation} onChange={(value => {
const name = value;
const id = this.state.affiliationOptions.filter(affiliationOption => affiliationOption.name === name)[0].id;
const affiliationOption = Setting.getArrayItem(this.state.affiliationOptions, "name", name);
const id = affiliationOption.id;
this.updateUserField('affiliation', name);
this.updateUserField('score', id);
})}>