diff --git a/ui/components/app/confirm-page-container/confirm-page-container.component.js b/ui/components/app/confirm-page-container/confirm-page-container.component.js index 9cc2e4286..c23c9b74e 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container.component.js +++ b/ui/components/app/confirm-page-container/confirm-page-container.component.js @@ -1,16 +1,20 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; import SenderToRecipient from '../../ui/sender-to-recipient'; import { PageContainerFooter } from '../../ui/page-container'; import EditGasPopover from '../edit-gas-popover'; import { EDIT_GAS_MODES } from '../../../../shared/constants/gas'; +import { getAddressBookEntry } from '../../../selectors'; +import * as actions from '../../../store/actions'; +import Dialog from '../../ui/dialog'; import { ConfirmPageContainerHeader, ConfirmPageContainerContent, ConfirmPageContainerNavigation, } from '.'; -export default class ConfirmPageContainer extends Component { +class ConfirmPageContainer extends Component { static contextTypes = { t: PropTypes.func, }; @@ -66,8 +70,29 @@ export default class ConfirmPageContainer extends Component { handleCloseEditGas: PropTypes.func, // Gas Popover currentTransaction: PropTypes.object.isRequired, + showAddToAddressBookModal: PropTypes.func, + contact: PropTypes.object, }; + maybeRenderAddContact() { + const { t } = this.context; + const { showAddToAddressBookModal, toAddress, contact = {} } = this.props; + + if (contact.name || toAddress === undefined) { + return null; + } + + return ( + showAddToAddressBookModal()} + > + {t('newAccountDetectedDialogMessage')} + + ); + } + render() { const { showEdit, @@ -149,6 +174,7 @@ export default class ConfirmPageContainer extends Component { /> )} +
{this.maybeRenderAddContact()}
{contentComponent || ( + dispatch( + actions.showModal({ + name: 'ADD_TO_ADDRESSBOOK', + recipient, + }), + ), + }; +} + +function mergeProps(stateProps, dispatchProps, ownProps) { + const { to, ...restStateProps } = stateProps; + return { + ...ownProps, + ...restStateProps, + showAddToAddressBookModal: () => + dispatchProps.showAddToAddressBookModal(to), + }; +} + +export default connect( + mapStateToProps, + mapDispatchToProps, + mergeProps, +)(ConfirmPageContainer);