mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
badebe017f
* Add UnitInput component * Add CurrencyInput component * Add UserPreferencedCurrencyInput component * Add UserPreferencedCurrencyDisplay component * Add updatePreferences action * Add styles for CurrencyInput, CurrencyDisplay, and UnitInput * Update SettingsTab page with Primary Currency toggle * Refactor currency displays and inputs to use UserPreferenced displays and inputs * Add TokenInput component * Add UserPreferencedTokenInput component * Use TokenInput in the send screen * Fix unit tests * Fix e2e and integration tests * Remove send/CurrencyDisplay component * Replace diamond unicode character with Eth logo. Fix typos
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
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)
|