aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/currency-display/currency-display.container.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-08-16 10:18:01 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-08-24 07:45:27 +0800
commitda0df790472c816d933e9b697e4dab1a429740a3 (patch)
treeaa29b66b2a8aa6f0bff0141664aef2a49ec0d291 /ui/app/components/currency-display/currency-display.container.js
parent6670bc0e09dacaf9a91031a348d1a551ed1e3987 (diff)
downloadtangerine-wallet-browser-da0df790472c816d933e9b697e4dab1a429740a3.tar
tangerine-wallet-browser-da0df790472c816d933e9b697e4dab1a429740a3.tar.gz
tangerine-wallet-browser-da0df790472c816d933e9b697e4dab1a429740a3.tar.bz2
tangerine-wallet-browser-da0df790472c816d933e9b697e4dab1a429740a3.tar.lz
tangerine-wallet-browser-da0df790472c816d933e9b697e4dab1a429740a3.tar.xz
tangerine-wallet-browser-da0df790472c816d933e9b697e4dab1a429740a3.tar.zst
tangerine-wallet-browser-da0df790472c816d933e9b697e4dab1a429740a3.zip
Add CurrencyDisplay and TokenCurrencyDisplay components
Diffstat (limited to 'ui/app/components/currency-display/currency-display.container.js')
-rw-r--r--ui/app/components/currency-display/currency-display.container.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/ui/app/components/currency-display/currency-display.container.js b/ui/app/components/currency-display/currency-display.container.js
new file mode 100644
index 000000000..b36bba52a
--- /dev/null
+++ b/ui/app/components/currency-display/currency-display.container.js
@@ -0,0 +1,20 @@
+import { connect } from 'react-redux'
+import CurrencyDisplay from './currency-display.component'
+import { getValueFromWeiHex, formatCurrency } from '../../helpers/confirm-transaction/util'
+import { ETH } from '../../constants/common'
+
+const mapStateToProps = (state, ownProps) => {
+ const { value, numberOfDecimals = 2, currency } = ownProps
+ const { metamask: { currentCurrency, conversionRate } } = state
+
+ const toCurrency = currency === ETH ? ETH : currentCurrency
+ const convertedValue = getValueFromWeiHex({ value, toCurrency, conversionRate, numberOfDecimals })
+ const formattedValue = formatCurrency(convertedValue, toCurrency)
+ const displayValue = `${formattedValue} ${toCurrency.toUpperCase()}`
+
+ return {
+ displayValue,
+ }
+}
+
+export default connect(mapStateToProps)(CurrencyDisplay)