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 // Receive IPC event for receiveCryptocurrency
export const receiveCryptocurrency = (event, currency) => (dispatch) => { export const receiveCryptocurrency = (event, currency) => (dispatch) => {
dispatch({ type: SET_CURRENCY, currency: cryptoTickers[currency] }) dispatch({ type: SET_CURRENCY, currency: cryptoTickers[currency] })
// dispatch({ type: SET_CRYPTO, crypto: cryptoTickers[currency] }) dispatch({ type: SET_CRYPTO, crypto: cryptoTickers[currency] })
dispatch({ type: SET_CRYPTO, crypto: 'ltc' }) // 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}`}> <li className={`${styles.currencies} ${styles.link}`}>
<span <span
data-hint={currentTicker ? currentTicker.price_usd : null} data-hint={currentTicker ? currentTicker.price_usd : null}
className={`${styles.currency} ${ticker.currency === 'btc' ? styles.active : ''} hint--bottom`} className={`${styles.currency} ${ticker.currency === ticker.crypto ? styles.active : ''} hint--bottom`}
onClick={() => setCurrency('btc')} onClick={() => setCurrency(ticker.crypto)}
> >
<CryptoIcon currency={ticker.crypto} /> <CryptoIcon currency={ticker.crypto} />
</span> </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 === 'usd' ? <FaDollar /> : <CryptoIcon currency={ticker.crypto} />}</span>
<span> <span>
{ {
ticker.currency === 'btc' ? ticker.currency === 'usd' ?
btc.satoshisToBtc(balance.walletBalance)
:
btc.satoshisToUsd(balance.walletBalance, currentTicker.price_usd) btc.satoshisToUsd(balance.walletBalance, currentTicker.price_usd)
:
btc.satoshisToBtc(balance.walletBalance)
} }
</span> </span>
</p> </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 === 'usd' ? <FaDollar /> : <CryptoIcon currency={ticker.crypto} />}</span>
<span> <span>
{ {
ticker.currency === 'btc' ? ticker.currency === 'usd' ?
btc.satoshisToBtc(balance.channelBalance)
:
btc.satoshisToUsd(balance.channelBalance, currentTicker.price_usd) btc.satoshisToUsd(balance.channelBalance, currentTicker.price_usd)
:
btc.satoshisToBtc(balance.channelBalance)
} }
</span> </span>
</p> </p>
@ -69,12 +69,6 @@ const Nav = ({ ticker, balance, setCurrency, formClicked, currentTicker }) => (
<span>Wallet</span> <span>Wallet</span>
</NavLink> </NavLink>
</li> </li>
<li>
<NavLink to='/settings' activeClassName={styles.active} className={styles.link}>
<MdSettings />
<span>Settings</span>
</NavLink>
</li>
</ul> </ul>
<div className={styles.buttons}> <div className={styles.buttons}>
<div className={styles.button} onClick={() => formClicked('pay')}> <div className={styles.button} onClick={() => formClicked('pay')}>

Loading…
Cancel
Save