diff --git a/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.js b/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.js index 8847c950..2a30909b 100644 --- a/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.js +++ b/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.js @@ -31,27 +31,29 @@ BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_HALF_UP }) const useStyles = makeStyles(styles) const Footer = () => { - const { data, loading } = useQuery(GET_DATA) + const { data } = useQuery(GET_DATA) const [expanded, setExpanded] = useState(false) const [delayedExpand, setDelayedExpand] = useState(null) + const withCommissions = R.path(['cryptoRates', 'withCommissions'])(data) ?? {} const classes = useStyles({ - bigFooter: R.keys(data?.cryptoRates?.withCommissions).length > 8, + bigFooter: R.keys(withCommissions).length > 8, expanded }) + const config = R.path(['config'])(data) ?? {} + const canExpand = R.keys(withCommissions).length > 4 - const canExpand = R.keys(data?.cryptoRates.withCommissions ?? []).length > 4 - - const wallets = fromNamespace('wallets')(data?.config) + const wallets = fromNamespace('wallets')(config) + const cryptoCurrencies = R.path(['cryptoCurrencies'])(data) ?? [] + const accountsConfig = R.path(['accountsConfig'])(data) ?? [] + const localeFiatCurrency = R.path(['locale_fiatCurrency'])(config) ?? '' const renderFooterItem = key => { - const idx = R.findIndex(R.propEq('code', key))(data.cryptoCurrencies) + const idx = R.findIndex(R.propEq('code', key))(cryptoCurrencies) const tickerCode = wallets[`${key}_ticker`] - const tickerIdx = R.findIndex(R.propEq('code', tickerCode))( - data.accountsConfig - ) + const tickerIdx = R.findIndex(R.propEq('code', tickerCode))(accountsConfig) - const tickerName = data.accountsConfig[tickerIdx].display + const tickerName = tickerIdx > -1 ? accountsConfig[tickerIdx].display : '' const cashInNoCommission = parseFloat( R.path(['cryptoRates', 'withoutCommissions', key, 'cashIn'])(data) @@ -74,12 +76,10 @@ const Footer = () => { ) ).toFormat(2) - const localeFiatCurrency = data.config.locale_fiatCurrency - return ( - {data.cryptoCurrencies[idx].display} + {cryptoCurrencies[idx].display}
@@ -116,15 +116,11 @@ const Footer = () => { onMouseEnter={handleMouseEnter} />
- {!loading && data && ( - - - {R.keys(data.cryptoRates.withCommissions).map(key => - renderFooterItem(key) - )} - + + + {R.keys(withCommissions).map(key => renderFooterItem(key))} - )} +