aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/send-v2.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-10-17 21:58:53 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-10-19 11:21:46 +0800
commit4915aff7505db7a1f042525a366ca0e7c6da1eed (patch)
tree1fe00002902037b9b1f9d2a115ec616c784c44e0 /ui/app/send-v2.js
parent03685c64b8e45d893c86478869200933de043da8 (diff)
downloadtangerine-wallet-browser-4915aff7505db7a1f042525a366ca0e7c6da1eed.tar
tangerine-wallet-browser-4915aff7505db7a1f042525a366ca0e7c6da1eed.tar.gz
tangerine-wallet-browser-4915aff7505db7a1f042525a366ca0e7c6da1eed.tar.bz2
tangerine-wallet-browser-4915aff7505db7a1f042525a366ca0e7c6da1eed.tar.lz
tangerine-wallet-browser-4915aff7505db7a1f042525a366ca0e7c6da1eed.tar.xz
tangerine-wallet-browser-4915aff7505db7a1f042525a366ca0e7c6da1eed.tar.zst
tangerine-wallet-browser-4915aff7505db7a1f042525a366ca0e7c6da1eed.zip
Breaks send-v2 down into renderable functions.
Diffstat (limited to 'ui/app/send-v2.js')
-rw-r--r--ui/app/send-v2.js261
1 files changed, 159 insertions, 102 deletions
diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js
index f04b95800..9f91af0e1 100644
--- a/ui/app/send-v2.js
+++ b/ui/app/send-v2.js
@@ -28,6 +28,9 @@ function SendTransactionScreen () {
memo: '',
dropdownOpen: false,
}
+
+ this.handleToChange = this.handleToChange.bind(this)
+ this.handleAmountChange = this.handleAmountChange.bind(this)
}
SendTransactionScreen.prototype.componentWillMount = function () {
@@ -97,149 +100,203 @@ SendTransactionScreen.prototype.renderCopy = function () {
])
}
-SendTransactionScreen.prototype.render = function () {
+SendTransactionScreen.prototype.renderHeader = function () {
+ return h('div', [
+ h('div.send-v2__header', {}, [
+
+ this.renderHeaderIcon(),
+
+ h('div.send-v2__arrow-background', [
+ h('i.fa.fa-lg.fa-arrow-circle-right.send-v2__send-arrow-icon'),
+ ]),
+
+ h('div.send-v2__header-tip'),
+
+ ]),
+
+ this.renderTitle(),
+
+ this.renderCopy(),
+ ])
+}
+
+SendTransactionScreen.prototype.renderFromRow = function () {
const {
accounts,
conversionRate,
- tokenToUSDRate,
- selectedToken,
- showCustomizeGasModal,
selectedAccount,
setSelectedAddress,
- primaryCurrency = 'ETH',
- gasLimit,
- gasPrice,
} = this.props
- const {
- dropdownOpen,
+ const { dropdownOpen } = this.state
+
+ return h('div.send-v2__form-row', [
+
+ h('div.send-v2__form-label', 'From:'),
+
+ h(FromDropdown, {
+ dropdownOpen,
+ accounts,
+ selectedAccount,
+ onSelect: address => setSelectedAddress(address),
+ openDropdown: () => this.setState({ dropdownOpen: true }),
+ closeDropdown: () => this.setState({ dropdownOpen: false }),
+ conversionRate,
+ }),
+
+ ])
+}
+
+SendTransactionScreen.prototype.handleToChange = function (event) {
+ const to = event.target.value
+
+ this.setState({
+ ...this.state,
to,
- amount,
- // gasLimit,
- // gasPrice,
- memo,
- } = this.state
+ })
+}
- const amountConversionRate = selectedToken ? tokenToUSDRate : conversionRate
+SendTransactionScreen.prototype.renderToRow = function () {
+ const { accounts } = this.props
+ const { to } = this.state
- return (
+ return h('div.send-v2__form-row', [
- h('div.send-v2__container', [
- h('div.send-v2__header', {}, [
+ h('div.send-v2__form-label', 'To:'),
- this.renderHeaderIcon(),
+ h(ToAutoComplete, {
+ to,
+ accounts,
+ onChange: this.handleToChange,
+ }),
- h('div.send-v2__arrow-background', [
- h('i.fa.fa-lg.fa-arrow-circle-right.send-v2__send-arrow-icon'),
- ]),
+ ])
+}
- h('div.send-v2__header-tip'),
+SendTransactionScreen.prototype.handleAmountChange = function (value) {
+ const amount = value
- ]),
+ this.setState({
+ ...this.state,
+ amount,
+ })
+}
+
+SendTransactionScreen.prototype.renderAmountRow = function () {
+ const {
+ conversionRate,
+ tokenToUSDRate,
+ selectedToken,
+ primaryCurrency = 'ETH',
+ } = this.props
- this.renderTitle(),
+ const { amount } = this.state
- this.renderCopy(),
+ const amountConversionRate = selectedToken ? tokenToUSDRate : conversionRate
+
+ return h('div.send-v2__form-row', [
+
+ h('div.send-v2__form-label', 'Amount:'),
+
+ h(CurrencyDisplay, {
+ primaryCurrency,
+ convertedCurrency: 'USD',
+ value: amount,
+ conversionRate: amountConversionRate,
+ convertedPrefix: '$',
+ handleChange: this.handleAmountChange
+ }),
+
+ ])
+}
+
+SendTransactionScreen.prototype.renderGasRow = function () {
+ const {
+ conversionRate,
+ showCustomizeGasModal,
+ gasLimit,
+ gasPrice,
+ } = this.props
- h('div.send-v2__form', {}, [
+ return h('div.send-v2__form-row', [
- h('div.send-v2__form-row', [
+ h('div.send-v2__form-label', 'Gas fee:'),
- h('div.send-v2__form-label', 'From:'),
+ h(GasFeeDisplay, {
+ gasLimit,
+ gasPrice,
+ conversionRate,
+ onClick: showCustomizeGasModal,
+ }),
- h(FromDropdown, {
- dropdownOpen,
- accounts,
- selectedAccount,
- onSelect: address => setSelectedAddress(address),
- openDropdown: () => this.setState({ dropdownOpen: true }),
- closeDropdown: () => this.setState({ dropdownOpen: false }),
- conversionRate,
- }),
+ h('div.send-v2__sliders-icon-container', {
+ onClick: showCustomizeGasModal,
+ }, [
+ h('i.fa.fa-sliders.send-v2__sliders-icon'),
+ ])
- ]),
+ ])
+}
- h('div.send-v2__form-row', [
+SendTransactionScreen.prototype.renderMemoRow = function () {
+ const { memo } = this.state
- h('div.send-v2__form-label', 'To:'),
+ return h('div.send-v2__form-row', [
- h(ToAutoComplete, {
- to,
- accounts,
- onChange: (event) => {
- this.setState({
- ...this.state,
- to: event.target.value,
- })
- },
- }),
+ h('div.send-v2__form-label', 'Transaction Memo:'),
- ]),
+ h(MemoTextArea, {
+ memo,
+ onChange: (event) => {
+ this.setState({
+ ...this.state,
+ memo: event.target.value,
+ })
+ },
+ }),
- h('div.send-v2__form-row', [
+ ])
+}
- h('div.send-v2__form-label', 'Amount:'),
+SendTransactionScreen.prototype.renderForm = function () {
+ return h('div.send-v2__form', {}, [
- h(CurrencyDisplay, {
- primaryCurrency,
- convertedCurrency: 'USD',
- value: amount,
- conversionRate: amountConversionRate,
- convertedPrefix: '$',
- handleChange: (value) => {
- this.setState({
- ...this.state,
- amount: value,
- })
- }
- }),
+ this.renderFromRow(),
- ]),
+ this.renderToRow(),
- h('div.send-v2__form-row', [
+ this.renderAmountRow(),
- h('div.send-v2__form-label', 'Gas fee:'),
+ this.renderGasRow(),
- h(GasFeeDisplay, {
- gasLimit,
- gasPrice,
- conversionRate,
- onClick: showCustomizeGasModal,
- }),
+ this.renderMemoRow(),
- h('div.send-v2__sliders-icon-container', {
- onClick: showCustomizeGasModal,
- }, [
- h('i.fa.fa-sliders.send-v2__sliders-icon'),
- ])
+ ])
+}
- ]),
+SendTransactionScreen.prototype.renderFooter = function () {
+ const { goHome } = this.props
- h('div.send-v2__form-row', [
+ return h('div.send-v2__footer', [
+ h('button.send-v2__cancel-btn', {
+ onClick: goHome,
+ }, 'Cancel'),
+ h('button.send-v2__next-btn', {
+ onClick: event => this.onSubmit(event),
+ }, 'Next'),
+ ])
+}
- h('div.send-v2__form-label', 'Transaction Memo:'),
+SendTransactionScreen.prototype.render = function () {
+ return (
- h(MemoTextArea, {
- memo,
- onChange: (event) => {
- this.setState({
- ...this.state,
- memo: event.target.value,
- })
- },
- }),
+ h('div.send-v2__container', [
- ]),
+ this.renderHeader(),
- ]),
+ this.renderForm(),
- // Buttons underneath card
- h('div.send-v2__footer', [
- h('button.send-v2__cancel-btn', {}, 'Cancel'),
- h('button.send-v2__next-btn', {
- onClick: event => this.onSubmit(event),
- }, 'Next'),
- ]),
+ this.renderFooter(),
])
)