aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/modals/edit-account-name-modal.js
diff options
context:
space:
mode:
authorChi Kei Chan <chikeichan@gmail.com>2018-01-20 07:29:36 +0800
committerChi Kei Chan <chikeichan@gmail.com>2018-01-20 07:29:36 +0800
commit77c545336b38aefc6105cde1799b18066df8bef9 (patch)
tree121a140131c8cb1f4b746d8f37d4a403b0910aad /ui/app/components/modals/edit-account-name-modal.js
parent98b5a62fa74aa6730a25df28dfe5032cfb487697 (diff)
parent4e63924e607a07f94ff0a741a036ab352b0b7a3f (diff)
downloadtangerine-wallet-browser-77c545336b38aefc6105cde1799b18066df8bef9.tar.gz
tangerine-wallet-browser-77c545336b38aefc6105cde1799b18066df8bef9.tar.zst
tangerine-wallet-browser-77c545336b38aefc6105cde1799b18066df8bef9.zip
Merge branch 'uat' into newmaster
Diffstat (limited to 'ui/app/components/modals/edit-account-name-modal.js')
-rw-r--r--ui/app/components/modals/edit-account-name-modal.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/ui/app/components/modals/edit-account-name-modal.js b/ui/app/components/modals/edit-account-name-modal.js
new file mode 100644
index 000000000..e2361140d
--- /dev/null
+++ b/ui/app/components/modals/edit-account-name-modal.js
@@ -0,0 +1,77 @@
+const Component = require('react').Component
+const h = require('react-hyperscript')
+const inherits = require('util').inherits
+const connect = require('react-redux').connect
+const actions = require('../../actions')
+const { getSelectedAccount } = require('../../selectors')
+
+function mapStateToProps (state) {
+ return {
+ selectedAccount: getSelectedAccount(state),
+ identity: state.appState.modal.modalState.identity,
+ }
+}
+
+function mapDispatchToProps (dispatch) {
+ return {
+ hideModal: () => {
+ dispatch(actions.hideModal())
+ },
+ saveAccountLabel: (account, label) => {
+ dispatch(actions.saveAccountLabel(account, label))
+ },
+ }
+}
+
+inherits(EditAccountNameModal, Component)
+function EditAccountNameModal (props) {
+ Component.call(this)
+
+ this.state = {
+ inputText: props.identity.name,
+ }
+}
+
+module.exports = connect(mapStateToProps, mapDispatchToProps)(EditAccountNameModal)
+
+EditAccountNameModal.prototype.render = function () {
+ const { hideModal, saveAccountLabel, identity } = this.props
+
+ return h('div', {}, [
+ h('div.flex-column.edit-account-name-modal-content', {
+ }, [
+
+ h('div.edit-account-name-modal-cancel', {
+ onClick: () => {
+ hideModal()
+ },
+ }, [
+ h('i.fa.fa-times'),
+ ]),
+
+ h('div.edit-account-name-modal-title', {
+ }, ['Edit Account Name']),
+
+ h('input.edit-account-name-modal-input', {
+ placeholder: identity.name,
+ onChange: (event) => {
+ this.setState({ inputText: event.target.value })
+ },
+ value: this.state.inputText,
+ }, []),
+
+ h('button.btn-clear.edit-account-name-modal-save-button', {
+ onClick: () => {
+ if (this.state.inputText.length !== 0) {
+ saveAccountLabel(identity.address, this.state.inputText)
+ hideModal()
+ }
+ },
+ disabled: this.state.inputText.length === 0,
+ }, [
+ 'SAVE',
+ ]),
+
+ ]),
+ ])
+}