import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Button from '../../../ui/button/button.component'; export default class AddToAddressBookModal extends Component { static contextTypes = { t: PropTypes.func, }; static propTypes = { hideModal: PropTypes.func.isRequired, addToAddressBook: PropTypes.func.isRequired, recipient: PropTypes.string.isRequired, }; state = { alias: '', }; onSave = async () => { const { recipient, addToAddressBook, hideModal } = this.props; await addToAddressBook(recipient, this.state.alias); hideModal(); }; onChange = (e) => { this.setState({ alias: e.target.value, }); }; onKeyPress = async (e) => { if (e.key === 'Enter' && this.state.alias) { this.onSave(); } }; render() { const { t } = this.context; return (