From da01dd4eb3537caefe3dbab24c483a0b02a33e84 Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 6 May 2021 12:28:28 +0200 Subject: [PATCH] Filter out fiat in hero coin selector --- .../CoinsDropdown/CoinsDropdown.js | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/components/Home/Hero/ExchangeWidget/CoinInput/CoinSelector/CoinsDropdown/CoinsDropdown.js b/src/components/Home/Hero/ExchangeWidget/CoinInput/CoinSelector/CoinsDropdown/CoinsDropdown.js index eeb6368a9..04ebdd1eb 100644 --- a/src/components/Home/Hero/ExchangeWidget/CoinInput/CoinSelector/CoinsDropdown/CoinsDropdown.js +++ b/src/components/Home/Hero/ExchangeWidget/CoinInput/CoinSelector/CoinsDropdown/CoinsDropdown.js @@ -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: '' }; @@ -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 => { @@ -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;