blowfish/src/components/Balance.jsx

25 lines
637 B
React
Raw Normal View History

2019-05-06 00:10:28 +02:00
import React from 'react'
import PropTypes from 'prop-types'
2019-05-08 21:41:24 +02:00
import { AppContext } from '../store/createContext'
import { locale } from '../util/moneyFormatter'
import { formatCurrency } from '@coingecko/cryptoformat'
2019-05-06 00:10:28 +02:00
2019-05-06 20:07:04 +02:00
const Balance = ({ balance }) => (
<h1 className="number">
2019-05-08 21:41:24 +02:00
<AppContext.Consumer>
{({ currency }) =>
formatCurrency(balance[currency], currency.toUpperCase(), locale)
.replace(/BTC/, 'Ƀ')
.replace(/ETH/, 'Ξ')
.replace(/OCEAN/, 'Ọ')
}
2019-05-08 21:41:24 +02:00
</AppContext.Consumer>
2019-05-06 20:07:04 +02:00
</h1>
)
2019-05-06 00:10:28 +02:00
Balance.propTypes = {
2019-05-06 18:16:30 +02:00
balance: PropTypes.object.isRequired
2019-05-06 00:10:28 +02:00
}
export default Balance