From a7b2d8fe5c9d088c959c8f73df088d15bfe31e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Let=C3=ADcia=20Camara?= Date: Tue, 30 Oct 2018 13:53:44 -0300 Subject: [PATCH] Add ambassor URL sort --- src/components/EnhancedTable.js | 18 ++++-------------- src/components/pages/AmbassadorsPage.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/components/EnhancedTable.js b/src/components/EnhancedTable.js index c2eb106..f42fb57 100644 --- a/src/components/EnhancedTable.js +++ b/src/components/EnhancedTable.js @@ -96,22 +96,12 @@ class EnhancedTable extends Component { ? this.state.data.sort((a, b) => { 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; + return ((b[orderBy].hasOwnProperty('searchText') ? b[orderBy].searchText.toLowerCase() : b[orderBy].toLowerCase()) < + (a[orderBy].hasOwnProperty('searchText') ? a[orderBy].searchText.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); + return ((a[orderBy].hasOwnProperty('searchText') ? a[orderBy].searchText.toLowerCase() : a[orderBy].toLowerCase()) < + (b[orderBy].hasOwnProperty('searchText') ? b[orderBy].searchText.toLowerCase() : b[orderBy].toLowerCase()) ? -1 : 1); }); this.setState({ data, order, orderBy }); diff --git a/src/components/pages/AmbassadorsPage.js b/src/components/pages/AmbassadorsPage.js index 07b8b16..b25c16a 100644 --- a/src/components/pages/AmbassadorsPage.js +++ b/src/components/pages/AmbassadorsPage.js @@ -150,8 +150,13 @@ class AmbassadorsPage extends Component { ) }; ambassador.map = app.addMapButton(ambassador, ambassador.cities); - ambassador.link = {stripProtocol(ambassador.url)}; + ambassador.link = { + searchText: stripProtocol(ambassador.url), + value: ( + {stripProtocol(ambassador.url)} + ) + }; }); // Once both return, update the state @@ -267,7 +272,7 @@ class AmbassadorsPage extends Component { const infoDescription =
Location: {(location.name).replace(/(^|\s)\S/g, l => l.toUpperCase())} - {countries.getName(location.country)}
{(ambassador.nickname) && (
Nickname: {ambassador.nickname}
)} - {(ambassador.telegram_original) && (
Telegram: + {(ambassador.telegram_original) && (
Telegram: