Fix ambassador's telegram sort

This commit is contained in:
Letícia Camara 2018-10-29 19:32:25 -03:00
parent f525d6ef40
commit 2300fa99ff

View file

@ -93,8 +93,26 @@ class EnhancedTable extends Component {
const data = const data =
order === 'desc' order === 'desc'
? this.state.data.sort((a, b) => (b[orderBy].toLowerCase() < a[orderBy].toLowerCase() ? -1 : 1)) ? this.state.data.sort((a, b) => {
: this.state.data.sort((a, b) => (a[orderBy].toLowerCase() < b[orderBy].toLowerCase() ? -1 : 1)); console.log(a[orderBy]);
console.log(b[orderBy]);
if(a[orderBy].hasOwnProperty('searchText')){
a[orderBy] = a[orderBy].searchText;
}
if(b[orderBy].hasOwnProperty('searchText')){
b[orderBy] = b[orderBy].searchText;
}
return b[orderBy].toLowerCase() < a[orderBy].toLowerCase() ? -1 : 1;
})
: this.state.data.sort((a, b) => {
if(a[orderBy].hasOwnProperty('searchText')){
a[orderBy] = a[orderBy].searchText;
}
if(b[orderBy].hasOwnProperty('searchText')){
b[orderBy] = b[orderBy].searchText;
}
return (a[orderBy].toLowerCase() < b[orderBy].toLowerCase() ? -1 : 1);
});
this.setState({ data, order, orderBy }); this.setState({ data, order, orderBy });
}; };