2018-06-04 18:33:25 +02:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import copyToClipboard from 'copy-to-clipboard'
|
2018-07-20 23:18:50 +02:00
|
|
|
import { addressSlicer } from '../../util'
|
2018-06-04 18:33:25 +02:00
|
|
|
|
|
|
|
const Tooltip = require('../tooltip-v2.js')
|
|
|
|
|
|
|
|
class SelectedAccount extends Component {
|
|
|
|
state = {
|
|
|
|
copied: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
selectedAddress: PropTypes.string,
|
|
|
|
selectedIdentity: PropTypes.object,
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { t } = this.context
|
|
|
|
const { selectedAddress, selectedIdentity } = this.props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="selected-account">
|
|
|
|
<Tooltip
|
|
|
|
position="bottom"
|
|
|
|
title={this.state.copied ? t('copiedExclamation') : t('copyToClipboard')}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className="selected-account__clickable"
|
|
|
|
onClick={() => {
|
|
|
|
this.setState({ copied: true })
|
|
|
|
setTimeout(() => this.setState({ copied: false }), 3000)
|
|
|
|
copyToClipboard(selectedAddress)
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className="selected-account__name">
|
|
|
|
{ selectedIdentity.name }
|
|
|
|
</div>
|
|
|
|
<div className="selected-account__address">
|
2018-07-20 23:18:50 +02:00
|
|
|
{ addressSlicer(selectedAddress) }
|
2018-06-04 18:33:25 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SelectedAccount
|