Add ambassor URL sort

This commit is contained in:
Letícia Camara 2018-10-30 13:53:44 -03:00
parent 2300fa99ff
commit a7b2d8fe5c
2 changed files with 12 additions and 17 deletions

View file

@ -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 });

View file

@ -150,8 +150,13 @@ class AmbassadorsPage extends Component {
)
};
ambassador.map = app.addMapButton(ambassador, ambassador.cities);
ambassador.link = <a target="_blank" rel="noopener noreferrer"
href={ambassador.url}>{stripProtocol(ambassador.url)}</a>;
ambassador.link = {
searchText: stripProtocol(ambassador.url),
value: (
<a target="_blank" rel="noopener noreferrer"
href={ambassador.url}>{stripProtocol(ambassador.url)}</a>
)
};
});
// Once both return, update the state
@ -267,7 +272,7 @@ class AmbassadorsPage extends Component {
const infoDescription = <div>
<div><b>Location</b>: {(location.name).replace(/(^|\s)\S/g, l => l.toUpperCase())} - {countries.getName(location.country)}</div>
{(ambassador.nickname) && (<div><b>Nickname</b>: {ambassador.nickname}</div>)}
{(ambassador.telegram_original) && (<div><b>Telegram</b>:
{(ambassador.telegram_original) && (<div><b>Telegram</b>:
<a
href={`https://t.me/${(ambassador.telegram_original.trim().charAt(0) === '@') ? ambassador.telegram_original.trim().slice(1): ambassador.telegram_original.trim()}`}
target="_blank"