diff --git a/src/components/EnhancedSearch.js b/src/components/EnhancedSearch.js index d3d43dc..e2cc4f6 100644 --- a/src/components/EnhancedSearch.js +++ b/src/components/EnhancedSearch.js @@ -42,7 +42,7 @@ const styles = theme => ({ class EnhancedSearch extends Component { render() { - const {query, onUpdateQuery, onColumnChange} = this.props; + const {query, onUpdateQuery, onColumnChange, textComponent} = this.props; const { classes } = this.props; return ( @@ -62,6 +62,7 @@ class EnhancedSearch extends Component { startAdornment: , }} /> + {textComponent}
{this.props.showSearchColumns && this.props.columns.map(column => ( {}, onDelete: () => {}, onMultipleDelete: () => {}, + description: '' }; /** @@ -87,6 +88,8 @@ class EnhancedTable extends Component { const orderBy = property; let order = 'desc'; + if(orderBy === 'map') return; + if (this.state.orderBy === property && this.state.order === 'desc') { order = 'asc'; } @@ -94,15 +97,15 @@ class EnhancedTable extends Component { const data = order === 'desc' ? this.state.data.sort((a, b) => { - let a_value = a[orderBy]; - let b_value = b[orderBy]; + let a_value = (a[orderBy] !== undefined) ? a[orderBy]: ''; + let b_value = (b[orderBy] !== undefined) ? b[orderBy]: ''; a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase(); b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase(); return (b_value < a_value) ? -1 : 1; }) : this.state.data.sort((a, b) => { - let a_value = a[orderBy]; - let b_value = b[orderBy]; + let a_value = (a[orderBy] !== undefined) ? a[orderBy]: ''; + let b_value = (b[orderBy] !== undefined) ? b[orderBy]: ''; a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase(); b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase(); if(a_value.trim() === '') a_value = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'; @@ -250,6 +253,7 @@ class EnhancedTable extends Component { return (
{ambassador.telegram} @@ -244,7 +246,7 @@ class AmbassadorsPage extends Component { addLocationSearchText(cities){ let searchText = ''; cities.forEach((location) => { - searchText += `${(location.name).replace(/(^|\s)\S/g, l => l.toUpperCase())} - ${countries.getName(location.country)} `; + searchText += `${countries.getName(location.country)} - ${(location.name).replace(/(^|\s)\S/g, l => l.toUpperCase())}`; }); return searchText; @@ -315,7 +317,7 @@ class AmbassadorsPage extends Component { } render() { - const { data } = this.state.ambassadors; + let { data } = this.state.ambassadors; const { ambassadorsSearch, merchantMarkers } = this.state; const ambassadorsMarkers = []; @@ -346,6 +348,18 @@ class AmbassadorsPage extends Component { }); }); + data = data.sort(sortBy('location.searchText')); + + const textComponent = ( + + + + + + + + ); + return (
@@ -356,21 +370,12 @@ class AmbassadorsPage extends Component {
-

{ /* Conditional Rendering */} {(this.state.loading) ? ( Loading ): (
-

- - - - - -

- this.closeMapsModal()} @@ -392,9 +397,10 @@ class AmbassadorsPage extends Component {

Address: {merchant.address}
{(merchant.phone) && (
Phone: {merchant.phone}
)}
; + merchant.location = { + searchText: `${merchant.country} - ${merchant.city}`, + value: (merchant.city) ? `${merchant.city} - ${merchant.country}`: merchant.country + } merchant.map =