Browse Source

fix(currency conditionals): conditionals based on usd and current crypto for multi-currency support

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
ebf185f931
  1. 4
      app/reducers/ticker.js
  2. 22
      app/routes/app/components/components/Nav.js

4
app/reducers/ticker.js

@ -56,8 +56,8 @@ export const fetchTicker = () => async (dispatch) => {
// Receive IPC event for receiveCryptocurrency
export const receiveCryptocurrency = (event, currency) => (dispatch) => {
dispatch({ type: SET_CURRENCY, currency: cryptoTickers[currency] })
// dispatch({ type: SET_CRYPTO, crypto: cryptoTickers[currency] })
dispatch({ type: SET_CRYPTO, crypto: 'ltc' })
dispatch({ type: SET_CRYPTO, crypto: cryptoTickers[currency] })
// dispatch({ type: SET_CRYPTO, crypto: 'ltc' })
}

22
app/routes/app/components/components/Nav.js

@ -14,8 +14,8 @@ const Nav = ({ ticker, balance, setCurrency, formClicked, currentTicker }) => (
<li className={`${styles.currencies} ${styles.link}`}>
<span
data-hint={currentTicker ? currentTicker.price_usd : null}
className={`${styles.currency} ${ticker.currency === 'btc' ? styles.active : ''} hint--bottom`}
onClick={() => setCurrency('btc')}
className={`${styles.currency} ${ticker.currency === ticker.crypto ? styles.active : ''} hint--bottom`}
onClick={() => setCurrency(ticker.crypto)}
>
<CryptoIcon currency={ticker.crypto} />
</span>
@ -31,10 +31,10 @@ const Nav = ({ ticker, balance, setCurrency, formClicked, currentTicker }) => (
<span>{ticker.currency === 'usd' ? <FaDollar /> : <CryptoIcon currency={ticker.crypto} />}</span>
<span>
{
ticker.currency === 'btc' ?
btc.satoshisToBtc(balance.walletBalance)
:
ticker.currency === 'usd' ?
btc.satoshisToUsd(balance.walletBalance, currentTicker.price_usd)
:
btc.satoshisToBtc(balance.walletBalance)
}
</span>
</p>
@ -42,10 +42,10 @@ const Nav = ({ ticker, balance, setCurrency, formClicked, currentTicker }) => (
<span>{ticker.currency === 'usd' ? <FaDollar /> : <CryptoIcon currency={ticker.crypto} />}</span>
<span>
{
ticker.currency === 'btc' ?
btc.satoshisToBtc(balance.channelBalance)
:
ticker.currency === 'usd' ?
btc.satoshisToUsd(balance.channelBalance, currentTicker.price_usd)
:
btc.satoshisToBtc(balance.channelBalance)
}
</span>
</p>
@ -69,12 +69,6 @@ const Nav = ({ ticker, balance, setCurrency, formClicked, currentTicker }) => (
<span>Wallet</span>
</NavLink>
</li>
<li>
<NavLink to='/settings' activeClassName={styles.active} className={styles.link}>
<MdSettings />
<span>Settings</span>
</NavLink>
</li>
</ul>
<div className={styles.buttons}>
<div className={styles.button} onClick={() => formClicked('pay')}>

Loading…
Cancel
Save