Fixed voters filter and search issue

This commit is contained in:
Mustafa Buyukcelebi 2019-08-21 12:57:32 +03:00
parent ee43ac7b4e
commit 377d6f23be
3 changed files with 16 additions and 17 deletions

View File

@ -1,4 +1,4 @@
import React, { PureComponent } from 'react';
import React, { Component } from 'react';
import { withNavigation } from 'react-navigation';
// Constants
@ -13,12 +13,7 @@ import VotersDisplayView from '../view/votersDisplayView';
*
*/
class VotersDisplayContainer extends PureComponent {
constructor(props) {
super(props);
this.state = {};
}
class VotersDisplayContainer extends Component {
_handleOnUserPress = username => {
const { navigation } = this.props;

View File

@ -1,4 +1,4 @@
import React, { PureComponent } from 'react';
import React, { Component } from 'react';
import { View, FlatList, Text } from 'react-native';
import { injectIntl } from 'react-intl';
@ -8,10 +8,9 @@ import { getTimeFromNow } from '../../../utils/time';
// Components
import { UserListItem } from '../../basicUIElements';
// Styles
// eslint-disable-next-line
import styles from './votersDisplayStyles';
class VotersDisplayView extends PureComponent {
class VotersDisplayView extends Component {
/* Props
* ------------------------------------------------
* @prop { type } name - Description....

View File

@ -1,10 +1,10 @@
import { PureComponent } from 'react';
import { Component } from 'react';
import { isBefore } from '../utils/time';
import ROUTES from '../constants/routeNames';
class AccountListContainer extends PureComponent {
class AccountListContainer extends Component {
/* Props
* ------------------------------------------------
* @prop { type } name - Description....
@ -15,6 +15,7 @@ class AccountListContainer extends PureComponent {
this.state = {
data: props.data,
filterResult: null,
filterIndex: '0',
};
}
@ -23,7 +24,7 @@ class AccountListContainer extends PureComponent {
// Component Functions
_handleSearch = (searchText, key) => {
const { data } = this.state;
const { data, filterIndex } = this.state;
const newData = data.filter(item => {
const itemName = item[key].toUpperCase();
@ -32,12 +33,16 @@ class AccountListContainer extends PureComponent {
return itemName.indexOf(_text) > -1;
});
this.setState({ filterResult: newData });
if (filterIndex !== '0') {
this._handleOnVotersDropdownSelect(filterIndex, '', newData);
} else {
this.setState({ filterResult: newData });
}
};
_handleOnVotersDropdownSelect = index => {
_handleOnVotersDropdownSelect = (index, text, oldData) => {
const { data } = this.state;
const _data = data;
const _data = Object.assign([], oldData || data);
switch (index) {
case '0':
@ -53,7 +58,7 @@ class AccountListContainer extends PureComponent {
break;
}
this.setState({ filterResult: _data });
this.setState({ filterResult: _data, filterIndex: index });
};
_handleOnUserPress = username => {