aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/user-preferenced-currency-display/user-preferenced-currency-display.container.js
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-10-21 13:59:53 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-10-21 13:59:53 +0800
commit9c1b2108f69334884473eb95758e2d1c02c984d6 (patch)
tree93f5255399307a28cb9380dc23c275b406403929 /ui/app/components/user-preferenced-currency-display/user-preferenced-currency-display.container.js
parent13820b6cc1801a420f39cdfecd7ccb5309dc597b (diff)
parentb0c649a4e3c68293e08e764bbf4d53939df88e2d (diff)
downloadtangerine-wallet-browser-9c1b2108f69334884473eb95758e2d1c02c984d6.tar
tangerine-wallet-browser-9c1b2108f69334884473eb95758e2d1c02c984d6.tar.gz
tangerine-wallet-browser-9c1b2108f69334884473eb95758e2d1c02c984d6.tar.bz2
tangerine-wallet-browser-9c1b2108f69334884473eb95758e2d1c02c984d6.tar.lz
tangerine-wallet-browser-9c1b2108f69334884473eb95758e2d1c02c984d6.tar.xz
tangerine-wallet-browser-9c1b2108f69334884473eb95758e2d1c02c984d6.tar.zst
tangerine-wallet-browser-9c1b2108f69334884473eb95758e2d1c02c984d6.zip
fix merge conflicts
Diffstat (limited to 'ui/app/components/user-preferenced-currency-display/user-preferenced-currency-display.container.js')
-rw-r--r--ui/app/components/user-preferenced-currency-display/user-preferenced-currency-display.container.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/ui/app/components/user-preferenced-currency-display/user-preferenced-currency-display.container.js b/ui/app/components/user-preferenced-currency-display/user-preferenced-currency-display.container.js
new file mode 100644
index 000000000..23240c649
--- /dev/null
+++ b/ui/app/components/user-preferenced-currency-display/user-preferenced-currency-display.container.js
@@ -0,0 +1,52 @@
+import { connect } from 'react-redux'
+import UserPreferencedCurrencyDisplay from './user-preferenced-currency-display.component'
+import { preferencesSelector } from '../../selectors'
+import { ETH, PRIMARY, SECONDARY } from '../../constants/common'
+
+const mapStateToProps = (state, ownProps) => {
+ const { useETHAsPrimaryCurrency } = preferencesSelector(state)
+
+ return {
+ useETHAsPrimaryCurrency,
+ }
+}
+
+const mergeProps = (stateProps, dispatchProps, ownProps) => {
+ const { useETHAsPrimaryCurrency, ...restStateProps } = stateProps
+ const {
+ type,
+ numberOfDecimals: propsNumberOfDecimals,
+ ethNumberOfDecimals,
+ fiatNumberOfDecimals,
+ ethPrefix,
+ fiatPrefix,
+ prefix: propsPrefix,
+ ...restOwnProps
+ } = ownProps
+
+ let currency, numberOfDecimals, prefix
+
+ if (type === PRIMARY && useETHAsPrimaryCurrency ||
+ type === SECONDARY && !useETHAsPrimaryCurrency) {
+ // Display ETH
+ currency = ETH
+ numberOfDecimals = propsNumberOfDecimals || ethNumberOfDecimals || 6
+ prefix = propsPrefix || ethPrefix
+ } else if (type === SECONDARY && useETHAsPrimaryCurrency ||
+ type === PRIMARY && !useETHAsPrimaryCurrency) {
+ // Display Fiat
+ numberOfDecimals = propsNumberOfDecimals || fiatNumberOfDecimals || 2
+ prefix = propsPrefix || fiatPrefix
+ }
+
+ return {
+ ...restStateProps,
+ ...dispatchProps,
+ ...restOwnProps,
+ currency,
+ numberOfDecimals,
+ prefix,
+ }
+}
+
+export default connect(mapStateToProps, null, mergeProps)(UserPreferencedCurrencyDisplay)