diff --git a/src/containers/accountListContainer.js b/src/containers/accountListContainer.js index 4d83cefad..4ce8d6c38 100644 --- a/src/containers/accountListContainer.js +++ b/src/containers/accountListContainer.js @@ -15,7 +15,7 @@ class AccountListContainer extends Component { this.state = { data: props.data, filterResult: null, - filterIndex: '0', + filterIndex: 0, }; } @@ -33,7 +33,7 @@ class AccountListContainer extends Component { return itemName.indexOf(_text) > -1; }); - if (filterIndex !== '0') { + if (filterIndex !== 0) { this._handleOnVotersDropdownSelect(filterIndex, '', newData); } else { this.setState({ filterResult: newData }); @@ -45,13 +45,13 @@ class AccountListContainer extends Component { const _data = Object.assign([], oldData || data); switch (index) { - case '0': + case 0: _data.sort((a, b) => Number(b.value) - Number(a.value)); break; - case '1': + case 1: _data.sort((a, b) => b.percent - a.percent); break; - case '2': + case 2: _data.sort((a, b) => (isBefore(a.time, b.time) ? 1 : -1)); break; default: @@ -74,7 +74,7 @@ class AccountListContainer extends Component { }; render() { - const { data, filterResult } = this.state; + const { data, filterResult, filterIndex } = this.state; const { children } = this.props; return ( @@ -82,6 +82,7 @@ class AccountListContainer extends Component { children({ data, filterResult, + filterIndex, handleOnVotersDropdownSelect: this._handleOnVotersDropdownSelect, handleSearch: this._handleSearch, handleOnUserPress: this._handleOnUserPress, diff --git a/src/screens/voters/screen/votersScreen.js b/src/screens/voters/screen/votersScreen.js index 14229ef31..353fbfd3a 100644 --- a/src/screens/voters/screen/votersScreen.js +++ b/src/screens/voters/screen/votersScreen.js @@ -23,7 +23,7 @@ const VotersScreen = ({ navigation }) => { return ( - {({ data, filterResult, handleOnVotersDropdownSelect, handleSearch }) => ( + {({ data, filterResult, filterIndex, handleOnVotersDropdownSelect, handleSearch }) => ( { id: `voters_dropdown.${item}`, }), )} - defaultText={intl.formatMessage({ id: `voters_dropdown.${filterOptions[0]}` })} + defaultText={intl.formatMessage({ + id: `voters_dropdown.${filterOptions[filterIndex]}`, + })} + selectedOptionIndex={filterIndex} onDropdownSelect={handleOnVotersDropdownSelect} />