import React, { Component } from 'react' import PropTypes from 'prop-types' import Identicon from '../identicon' import Tooltip from '../tooltip-v2' import copyToClipboard from 'copy-to-clipboard' export default class SenderToRecipient extends Component { static propTypes = { senderName: PropTypes.string, senderAddress: PropTypes.string, recipientName: PropTypes.string, recipientAddress: PropTypes.string, t: PropTypes.func, } static contextTypes = { t: PropTypes.func, } state = { senderAddressCopied: false, recipientAddressCopied: false, } renderRecipientWithAddress () { const { t } = this.context const { recipientName, recipientAddress } = this.props return (
{ this.setState({ recipientAddressCopied: true }) copyToClipboard(recipientAddress) }} >
this.setState({ recipientAddressCopied: false })} >
{ recipientName || this.context.t('newContract') }
) } renderRecipientWithoutAddress () { return (
{ this.context.t('newContract') }
) } render () { const { t } = this.context const { senderName, senderAddress, recipientAddress } = this.props return (
{ this.setState({ senderAddressCopied: true }) copyToClipboard(senderAddress) }} >
this.setState({ senderAddressCopied: false })} >
{ senderName }
{ recipientAddress ? this.renderRecipientWithAddress() : this.renderRecipientWithoutAddress() }
) } }