Sort ambassador by country and city on component load

This commit is contained in:
Letícia Camara 2018-11-02 18:25:50 -03:00
parent 8fe0954587
commit b782cfcd84

View file

@ -3,6 +3,7 @@ import { FormattedMessage, FormattedHTMLMessage } from 'react-intl';
import Modal from 'react-modal'; import Modal from 'react-modal';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import sortBy from 'sort-by';
// Custom components // Custom components
import AppHeader from '../AppHeader'; import AppHeader from '../AppHeader';
@ -143,7 +144,8 @@ class AmbassadorsPage extends Component {
searchText: ambassador.telegram, searchText: ambassador.telegram,
value: ( value: (
<a <a
href={`https://t.me/${(ambassador.telegram.trim().charAt(0) === '@') ? ambassador.telegram.trim().slice(1): ambassador.telegram.trim()}`} href={`https://t.me/${(ambassador.telegram.trim().charAt(0) === '@') ?
ambassador.telegram.trim().slice(1): ambassador.telegram.trim()}`}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
>{ambassador.telegram}</a> >{ambassador.telegram}</a>
@ -315,7 +317,7 @@ class AmbassadorsPage extends Component {
} }
render() { render() {
const { data } = this.state.ambassadors; let { data } = this.state.ambassadors;
const { ambassadorsSearch, merchantMarkers } = this.state; const { ambassadorsSearch, merchantMarkers } = this.state;
const ambassadorsMarkers = []; const ambassadorsMarkers = [];
@ -346,6 +348,8 @@ class AmbassadorsPage extends Component {
}); });
}); });
data = data.sort(sortBy('location.searchText'));
return ( return (
<div> <div>
<AppHeader /> <AppHeader />