Sort merchants by country and city on component load

This commit is contained in:
Letícia Camara 2018-11-02 19:11:40 -03:00
parent b782cfcd84
commit 23318a59e8

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';
@ -258,7 +259,7 @@ class MerchantsPage extends Component {
} }
render() { render() {
const { data: merchantsData } = this.state.merchants; let { data: merchantsData } = this.state.merchants;
const { ambassadorsMarkers, merchantsSearch } = this.state; const { ambassadorsMarkers, merchantsSearch } = this.state;
const merchantMarkers = merchantsSearch.map(merchant => { const merchantMarkers = merchantsSearch.map(merchant => {
@ -276,6 +277,8 @@ class MerchantsPage extends Component {
return marker; return marker;
}); });
merchantsData = merchantsData.sort(sortBy('location.searchText'));
return ( return (
<div> <div>