Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Tokens/Tokens.js
Show All 28 Lines | const Tokens = ({ jestBCH }) => { | ||||
If any user is still migrating at this point, this page will display a loading spinner until | If any user is still migrating at this point, this page will display a loading spinner until | ||||
their wallet has updated (ETA within 10 seconds) | their wallet has updated (ETA within 10 seconds) | ||||
Going forward, this approach will be the model for Wallet, Send, and SendToken, as the legacy | Going forward, this approach will be the model for Wallet, Send, and SendToken, as the legacy | ||||
wallet state parameters not stored in the wallet object are deprecated | wallet state parameters not stored in the wallet object are deprecated | ||||
*/ | */ | ||||
const { loading, wallet, apiError, fiatPrice } = React.useContext( | const { | ||||
WalletContext, | loading, | ||||
); | wallet, | ||||
apiError, | |||||
fiatPrice, | |||||
cashtabSettings, | |||||
} = React.useContext(WalletContext); | |||||
// If wallet is unmigrated, do not show page until it has migrated | // If wallet is unmigrated, do not show page until it has migrated | ||||
// An invalid wallet will be validated/populated after the next API call, ETA 10s | // An invalid wallet will be validated/populated after the next API call, ETA 10s | ||||
let validWallet = isValidStoredWallet(wallet); | let validWallet = isValidStoredWallet(wallet); | ||||
// Get wallet state variables | // Get wallet state variables | ||||
let balances, tokens; | let balances, tokens; | ||||
if (validWallet) { | if (validWallet) { | ||||
Show All 25 Lines | return ( | ||||
<> | <> | ||||
<BalanceHeader> | <BalanceHeader> | ||||
{formatBalance(balances.totalBalance)}{' '} | {formatBalance(balances.totalBalance)}{' '} | ||||
{currency.ticker} | {currency.ticker} | ||||
</BalanceHeader> | </BalanceHeader> | ||||
{fiatPrice !== null && | {fiatPrice !== null && | ||||
!isNaN(balances.totalBalance) && ( | !isNaN(balances.totalBalance) && ( | ||||
<BalanceHeaderFiat> | <BalanceHeaderFiat> | ||||
$ | {cashtabSettings | ||||
? `${ | |||||
currency.fiatCurrencies[ | |||||
cashtabSettings | |||||
.fiatCurrency | |||||
].symbol | |||||
} ` | |||||
: '$ '} | |||||
{( | {( | ||||
balances.totalBalance * fiatPrice | balances.totalBalance * fiatPrice | ||||
).toFixed(2)}{' '} | ).toFixed(2)}{' '} | ||||
USD | {cashtabSettings | ||||
? `${currency.fiatCurrencies[ | |||||
cashtabSettings.fiatCurrency | |||||
].slug.toUpperCase()} ` | |||||
: 'USD'} | |||||
</BalanceHeaderFiat> | </BalanceHeaderFiat> | ||||
)} | )} | ||||
</> | </> | ||||
)} | )} | ||||
{apiError && ( | {apiError && ( | ||||
<> | <> | ||||
<p | <p | ||||
style={{ | style={{ | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |