Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out fiat in hero coin selector #777

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getMatchingCoins } from 'Utils/walletAddress';
import debounce from 'Utils/debounce';
import styles from './CoinsDropdown.scss';


class CoinsDropdown extends Component {
state = { value: '' };

Expand Down Expand Up @@ -38,7 +37,7 @@ class CoinsDropdown extends Component {
};

trackEvent = debounce(coinSearched => {
window.gtag('event', 'Coins dropdown search', {event_category: 'Order', event_label: `${this.props.type} - ${coinSearched}`});
window.gtag('event', 'Coins dropdown search', { event_category: 'Order', event_label: `${this.props.type} - ${coinSearched}` });
}, 100);

searchCoins = coins => {
Expand All @@ -59,23 +58,35 @@ class CoinsDropdown extends Component {
const params = urlParams();
let filteredCoins = this.props.coinsInfo.filter(coin => {
if (params && params.hasOwnProperty('test')) {
return this.props.type.toUpperCase() === 'DEPOSIT' ? coin.is_quote_of_enabled_pair_for_test : coin.is_base_of_enabled_pair_for_test;
return this.props.type.toUpperCase() === 'DEPOSIT'
? coin.is_quote_of_enabled_pair_for_testto
: coin.is_base_of_enabled_pair_for_test;
}

return this.props.type.toUpperCase() === 'DEPOSIT' ? coin.is_quote_of_enabled_pair : coin.is_base_of_enabled_pair;
});

//Filter out fiat for deposit
filteredCoins = filteredCoins.filter(coin => coin.is_crypto || this.props.type.toUpperCase() !== 'DEPOSIT');

//Non cryptos first, then alphabetical
filteredCoins = _.sortBy(filteredCoins, (coin) => {return coin.is_crypto + coin.code});
filteredCoins = _.sortBy(filteredCoins, coin => {
return coin.is_crypto + coin.code;
});
filteredCoins = this.searchCoins(filteredCoins);

if (this.props.selectedCoin.orderByAddress && this.props.type.toUpperCase() === 'RECEIVE') {
const matchingCoins = getMatchingCoins(this.props.wallet.address);
filteredCoins = _.sortBy(filteredCoins, (coin) => {return matchingCoins.indexOf(coin.code) === -1});
const matchingCoins = getMatchingCoins(this.props.wallet.address);
filteredCoins = _.sortBy(filteredCoins, coin => {
return matchingCoins.indexOf(coin.code) === -1;
});
}

if(_.isEmpty(filteredCoins)){
if (_.isEmpty(filteredCoins)) {
/* eslint max-len: ["error", { "code": 200 }] */
window.gtag('event', 'Coins dropdown search - Not Found', {event_category: 'Order', event_label: `${this.props.type} - ${this.state.value}`});
window.gtag('event', 'Coins dropdown search - Not Found', {
event_category: 'Order',
event_label: `${this.props.type} - ${this.state.value}`,
});
}

return filteredCoins;
Expand Down