2018-04-07 00:29:51 +02:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2018-05-15 14:29:23 +02:00
|
|
|
import SendRowWrapper from '../send-row-wrapper/'
|
2018-04-26 18:38:38 +02:00
|
|
|
import EnsInput from '../../../ens-input'
|
2018-05-23 18:43:25 +02:00
|
|
|
import { getToErrorObject } from './send-to-row.utils.js'
|
2018-04-07 00:29:51 +02:00
|
|
|
|
|
|
|
export default class SendToRow extends Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
2018-04-27 02:38:14 +02:00
|
|
|
closeToDropdown: PropTypes.func,
|
|
|
|
inError: PropTypes.bool,
|
|
|
|
network: PropTypes.string,
|
|
|
|
openToDropdown: PropTypes.func,
|
2018-04-07 00:29:51 +02:00
|
|
|
to: PropTypes.string,
|
|
|
|
toAccounts: PropTypes.array,
|
|
|
|
toDropdownOpen: PropTypes.bool,
|
2018-05-23 18:43:25 +02:00
|
|
|
updateGas: PropTypes.func,
|
2018-04-07 00:29:51 +02:00
|
|
|
updateSendTo: PropTypes.func,
|
|
|
|
updateSendToError: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleToChange (to, nickname = '') {
|
2018-05-23 18:43:25 +02:00
|
|
|
const { updateSendTo, updateSendToError, updateGas } = this.props
|
|
|
|
const toErrorObject = getToErrorObject(to)
|
2018-04-07 00:29:51 +02:00
|
|
|
updateSendTo(to, nickname)
|
2018-05-23 18:43:25 +02:00
|
|
|
updateSendToError(toErrorObject)
|
|
|
|
if (toErrorObject.to === null) {
|
|
|
|
updateGas({ to })
|
|
|
|
}
|
2018-04-07 00:29:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
closeToDropdown,
|
|
|
|
inError,
|
2018-04-27 02:38:14 +02:00
|
|
|
network,
|
|
|
|
openToDropdown,
|
2018-04-26 18:38:38 +02:00
|
|
|
to,
|
2018-04-27 02:38:14 +02:00
|
|
|
toAccounts,
|
2018-04-26 18:38:38 +02:00
|
|
|
toDropdownOpen,
|
2018-04-07 00:29:51 +02:00
|
|
|
} = this.props
|
|
|
|
|
|
|
|
return (
|
2018-04-11 16:21:54 +02:00
|
|
|
<SendRowWrapper
|
2018-04-27 02:38:14 +02:00
|
|
|
errorType={'to'}
|
2018-05-25 03:00:07 +02:00
|
|
|
label={`${this.context.t('to')}`}
|
2018-04-11 16:21:54 +02:00
|
|
|
showError={inError}
|
|
|
|
>
|
2018-04-07 00:29:51 +02:00
|
|
|
<EnsInput
|
|
|
|
accounts={toAccounts}
|
|
|
|
closeDropdown={() => closeToDropdown()}
|
2018-04-27 02:38:14 +02:00
|
|
|
dropdownOpen={toDropdownOpen}
|
2018-04-07 00:29:51 +02:00
|
|
|
inError={inError}
|
2018-04-27 02:38:14 +02:00
|
|
|
name={'address'}
|
|
|
|
network={network}
|
|
|
|
onChange={(newTo, newNickname) => this.handleToChange(newTo, newNickname)}
|
|
|
|
openDropdown={() => openToDropdown()}
|
|
|
|
placeholder={this.context.t('recipientAddress')}
|
|
|
|
to={to}
|
2018-04-07 00:29:51 +02:00
|
|
|
/>
|
|
|
|
</SendRowWrapper>
|
2018-04-27 02:38:14 +02:00
|
|
|
)
|
2018-04-07 00:29:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SendToRow.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|