aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send_/send-content/send-to-row
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/components/send_/send-content/send-to-row')
-rw-r--r--ui/app/components/send_/send-content/send-to-row/send-to-row-README.md0
-rw-r--r--ui/app/components/send_/send-content/send-to-row/send-to-row.component.js62
-rw-r--r--ui/app/components/send_/send-content/send-to-row/send-to-row.container.js43
-rw-r--r--ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js14
-rw-r--r--ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js17
-rw-r--r--ui/app/components/send_/send-content/send-to-row/tests/send-to-row-component.test.js0
-rw-r--r--ui/app/components/send_/send-content/send-to-row/tests/send-to-row-container.test.js0
-rw-r--r--ui/app/components/send_/send-content/send-to-row/tests/send-to-row-selectors.test.js0
8 files changed, 136 insertions, 0 deletions
diff --git a/ui/app/components/send_/send-content/send-to-row/send-to-row-README.md b/ui/app/components/send_/send-content/send-to-row/send-to-row-README.md
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/send-to-row-README.md
diff --git a/ui/app/components/send_/send-content/send-to-row/send-to-row.component.js b/ui/app/components/send_/send-content/send-to-row/send-to-row.component.js
new file mode 100644
index 000000000..abcb54efc
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/send-to-row.component.js
@@ -0,0 +1,62 @@
+import React, { Component } from 'react'
+import PropTypes from 'prop-types'
+import SendRowWrapper from '../../../send/from-dropdown'
+import ToDropdown from '../../../ens-input'
+
+export default class SendToRow extends Component {
+
+ static propTypes = {
+ to: PropTypes.string,
+ toAccounts: PropTypes.array,
+ toDropdownOpen: PropTypes.bool,
+ inError: PropTypes.bool,
+ updateSendTo: PropTypes.func,
+ updateSendToError: PropTypes.func,
+ openToDropdown: PropTypes.func,
+ closeToDropdown: PropTypes.func,
+ network: PropTypes.number,
+ };
+
+ handleToChange (to, nickname = '') {
+ const { updateSendTo, updateSendToError } = this.props
+ updateSendTo(to, nickname)
+ updateSendErrors(to)
+ }
+
+ render () {
+ const {
+ from,
+ fromAccounts,
+ conversionRate,
+ fromDropdownOpen,
+ tokenContract,
+ openToDropdown,
+ closeToDropdown,
+ network,
+ inError,
+ } = this.props
+
+ return (
+ <SendRowWrapper label={`${this.context.t('to')}:`}>
+ <EnsInput
+ name={'address'}
+ placeholder={this.context.t('recipient Address')}
+ network={network},
+ to={to},
+ accounts={toAccounts}
+ dropdownOpen={toDropdownOpen}
+ openDropdown={() => openToDropdown()}
+ closeDropdown={() => closeToDropdown()}
+ onChange={this.handleToChange}
+ inError={inError}
+ />
+ </SendRowWrapper>
+ );
+ }
+
+}
+
+SendToRow.contextTypes = {
+ t: PropTypes.func,
+}
+
diff --git a/ui/app/components/send_/send-content/send-to-row/send-to-row.container.js b/ui/app/components/send_/send-content/send-to-row/send-to-row.container.js
new file mode 100644
index 000000000..1c446c168
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/send-to-row.container.js
@@ -0,0 +1,43 @@
+import {
+ getSendTo,
+ getToAccounts,
+ getCurrentNetwork,
+} from '../../send.selectors.js'
+import {
+ getToDropdownOpen,
+ sendToIsInError,
+} from './send-to-row.selectors.js'
+import { getToErrorObject } from './send-to-row.utils.js'
+import {
+ updateSendErrors,
+ updateSendTo,
+} from '../../../actions'
+import {
+ openToDropdown,
+ closeToDropdown,
+} from '../../../ducks/send'
+import SendToRow from './send-to-row.component'
+
+export default connect(mapStateToProps, mapDispatchToProps)(SendToRow)
+
+function mapStateToProps (state) {
+ updateSendTo
+ return {
+ to: getSendTo(state),
+ toAccounts: getSendToAccounts(state),
+ toDropdownOpen: getToDropdownOpen(state),
+ inError: sendToIsInError(state),
+ network: getCurrentNetwork(state),
+ }
+}
+
+function mapDispatchToProps (dispatch) {
+ return {
+ updateSendToError: (to) => {
+ dispatch(updateSendErrors(getToErrorObject(to)))
+ },
+ updateSendTo: (to, nickname) => dispatch(updateSendTo(to, nickname)),
+ openToDropdown: () => dispatch(()),
+ closeToDropdown: () => dispatch(()),
+ }
+} \ No newline at end of file
diff --git a/ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js b/ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js
new file mode 100644
index 000000000..05bb65fa3
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/send-to-row.selectors.js
@@ -0,0 +1,14 @@
+const selectors = {
+ getToDropdownOpen,
+ sendToIsInError,
+}
+
+module.exports = selectors
+
+function getToDropdownOpen (state) {
+ return state.send.toDropdownOpen
+}
+
+function sendToIsInError (state) {
+ return Boolean(state.metamask.send.to)
+}
diff --git a/ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js b/ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js
new file mode 100644
index 000000000..52bfde009
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/send-to-row.utils.js
@@ -0,0 +1,17 @@
+const { isValidAddress } = require('../../../../util')
+
+function getToErrorObject (to) {
+ let toError = null
+
+ if (!to) {
+ toError = 'required'
+ } else if (!isValidAddress(to)) {
+ toError = 'invalidAddressRecipient'
+ }
+
+ return { to: toError }
+}
+
+module.exports = {
+ getToErrorObject
+}
diff --git a/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-component.test.js b/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-component.test.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-component.test.js
diff --git a/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-container.test.js b/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-container.test.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-container.test.js
diff --git a/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-selectors.test.js b/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-selectors.test.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ui/app/components/send_/send-content/send-to-row/tests/send-to-row-selectors.test.js