A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/ui/app/components/send_/send-content/send-amount-row/send-amount-row.component.js

91 lines
2.1 KiB

7 years ago
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import SendRowWrapper from '../send-row-wrapper/send-row-wrapper.component'
import AmountMaxButton from './amount-max-button/amount-max-button.component'
7 years ago
import CurrencyDisplay from '../../../send/currency-display'
export default class SendAmountRow extends Component {
static propTypes = {
amountConversionRate: PropTypes.number,
conversionRate: PropTypes.number,
7 years ago
gasTotal: PropTypes.string,
primaryCurrency: PropTypes.string,
selectedToken: PropTypes.object,
tokenBalance: PropTypes.string,
updateSendAmountError: PropTypes.func,
updateSendAmount: PropTypes.func,
setMaxModeTo: PropTypes.func
}
validateAmount (amount) {
const {
amountConversionRate,
conversionRate,
balance,
7 years ago
gasTotal,
primaryCurrency,
selectedToken,
tokenBalance,
updateSendAmountError,
} = this.props
updateSendAmountError({
amount,
amountConversionRate,
balance,
conversionRate,
gasTotal,
primaryCurrency,
selectedToken,
tokenBalance,
})
}
handleAmountChange (amount) {
const { updateSendAmount, setMaxModeTo } = this.props
setMaxModeTo(false)
this.validateAmount(amount)
updateSendAmount(amount)
}
render () {
const {
amount,
amountConversionRate,
convertedCurrency,
inError,
gasTotal,
maxModeOn,
primaryCurrency = 'ETH',
selectedToken,
} = this.props
return (
<SendRowWrapper
label={`${this.context.t('amount')}:`}
showError={inError}
errorType={'amount'}
>
{!inError && gasTotal && <AmountMaxButton />}
7 years ago
<CurrencyDisplay
inError={inError}
primaryCurrency={primaryCurrency}
convertedCurrency={convertedCurrency}
selectedToken={selectedToken}
value={amount || '0x0'}
conversionRate={amountConversionRate}
handleChange={newAmount => this.handleAmountChange(newAmount)}
/>
7 years ago
</SendRowWrapper>
);
}
}
SendAmountRow.contextTypes = {
t: PropTypes.func,
}