2018-10-17 01:03:29 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import CurrencyInput from './currency-input.component'
|
|
|
|
import { ETH } from '../../constants/common'
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
2018-10-26 10:26:43 +02:00
|
|
|
const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state
|
2018-10-17 01:03:29 +02:00
|
|
|
|
|
|
|
return {
|
2018-10-26 10:26:43 +02:00
|
|
|
nativeCurrency,
|
2018-10-17 01:03:29 +02:00
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
2018-10-26 10:26:43 +02:00
|
|
|
const { nativeCurrency, currentCurrency } = stateProps
|
2018-10-17 01:03:29 +02:00
|
|
|
const { useFiat } = ownProps
|
2018-10-26 10:26:43 +02:00
|
|
|
const suffix = useFiat ? currentCurrency.toUpperCase() : nativeCurrency || ETH
|
2018-10-17 01:03:29 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
...stateProps,
|
|
|
|
...dispatchProps,
|
|
|
|
...ownProps,
|
|
|
|
suffix,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, null, mergeProps)(CurrencyInput)
|