|
|
@ -26,9 +26,9 @@ export default class EditContact extends PureComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
state = { |
|
|
|
state = { |
|
|
|
newName: '', |
|
|
|
newName: this.props.name, |
|
|
|
newAddress: '', |
|
|
|
newAddress: this.props.address, |
|
|
|
newMemo: '', |
|
|
|
newMemo: this.props.memo, |
|
|
|
error: '', |
|
|
|
error: '', |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -59,8 +59,7 @@ export default class EditContact extends PureComponent { |
|
|
|
<TextField |
|
|
|
<TextField |
|
|
|
type="text" |
|
|
|
type="text" |
|
|
|
id="nickname" |
|
|
|
id="nickname" |
|
|
|
placeholder={this.context.t('addAlias')} |
|
|
|
value={this.state.newName} |
|
|
|
value={this.state.newName || name} |
|
|
|
|
|
|
|
onChange={e => this.setState({ newName: e.target.value })} |
|
|
|
onChange={e => this.setState({ newName: e.target.value })} |
|
|
|
fullWidth |
|
|
|
fullWidth |
|
|
|
margin="dense" |
|
|
|
margin="dense" |
|
|
@ -74,8 +73,7 @@ export default class EditContact extends PureComponent { |
|
|
|
<TextField |
|
|
|
<TextField |
|
|
|
type="text" |
|
|
|
type="text" |
|
|
|
id="address" |
|
|
|
id="address" |
|
|
|
placeholder={address} |
|
|
|
value={this.state.newAddress} |
|
|
|
value={this.state.newAddress || address} |
|
|
|
|
|
|
|
error={this.state.error} |
|
|
|
error={this.state.error} |
|
|
|
onChange={e => this.setState({ newAddress: e.target.value })} |
|
|
|
onChange={e => this.setState({ newAddress: e.target.value })} |
|
|
|
fullWidth |
|
|
|
fullWidth |
|
|
@ -91,7 +89,7 @@ export default class EditContact extends PureComponent { |
|
|
|
type="text" |
|
|
|
type="text" |
|
|
|
id="memo" |
|
|
|
id="memo" |
|
|
|
placeholder={memo} |
|
|
|
placeholder={memo} |
|
|
|
value={this.state.newMemo || memo} |
|
|
|
value={this.state.newMemo} |
|
|
|
onChange={e => this.setState({ newMemo: e.target.value })} |
|
|
|
onChange={e => this.setState({ newMemo: e.target.value })} |
|
|
|
fullWidth |
|
|
|
fullWidth |
|
|
|
margin="dense" |
|
|
|
margin="dense" |
|
|
@ -110,12 +108,12 @@ export default class EditContact extends PureComponent { |
|
|
|
if (this.state.newAddress !== '' && this.state.newAddress !== address) { |
|
|
|
if (this.state.newAddress !== '' && this.state.newAddress !== address) { |
|
|
|
// if the user makes a valid change to the address field, remove the original address
|
|
|
|
// if the user makes a valid change to the address field, remove the original address
|
|
|
|
if (isValidAddress(this.state.newAddress)) { |
|
|
|
if (isValidAddress(this.state.newAddress)) { |
|
|
|
removeFromAddressBook(address) |
|
|
|
removeFromAddressBook(chainId, address) |
|
|
|
addToAddressBook(this.state.newAddress, this.state.newName || name, this.state.newMemo || memo) |
|
|
|
addToAddressBook(this.state.newAddress, this.state.newName || name, this.state.newMemo || memo) |
|
|
|
setAccountLabel(this.state.newAddress, this.state.newName || name) |
|
|
|
setAccountLabel(this.state.newAddress, this.state.newName || name) |
|
|
|
history.push(listRoute) |
|
|
|
history.push(listRoute) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.setState({ error: 'invalid address' }) |
|
|
|
this.setState({ error: this.context.t('invalidAddress') }) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// update name
|
|
|
|
// update name
|
|
|
|