import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Button from '../../../ui/button/button.component'; import { ButtonIcon, IconName } from '../../../component-library'; export default class NewAccountModal extends Component { static contextTypes = { t: PropTypes.func, }; static propTypes = { hideModal: PropTypes.func.isRequired, newAccountNumber: PropTypes.number.isRequired, onSave: PropTypes.func.isRequired, }; state = { alias: this.context.t('newAccountNumberName', [ this.props.newAccountNumber, ]), }; onChange = (e) => { this.setState({ alias: e.target.value, }); }; onSubmit = () => { this.props.onSave(this.state.alias).then(this.props.hideModal); }; onKeyPress = (e) => { if (e.key === 'Enter' && this.state.alias) { this.onSubmit(); } }; render() { const { t } = this.context; return (