You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.4 KiB
95 lines
2.4 KiB
6 years ago
|
import React, { PureComponent } from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
|
import Button from '../button'
|
||
|
import Identicon from '../identicon'
|
||
|
import TokenBalance from '../token-balance'
|
||
6 years ago
|
import CurrencyDisplay from '../currency-display'
|
||
6 years ago
|
import { SEND_ROUTE } from '../../routes'
|
||
6 years ago
|
import { ETH } from '../../constants/common'
|
||
6 years ago
|
|
||
6 years ago
|
export default class TransactionViewBalance extends PureComponent {
|
||
6 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
|
}
|
||
|
|
||
|
static propTypes = {
|
||
|
showDepositModal: PropTypes.func,
|
||
|
selectedToken: PropTypes.object,
|
||
|
history: PropTypes.object,
|
||
|
network: PropTypes.string,
|
||
6 years ago
|
balance: PropTypes.string,
|
||
6 years ago
|
}
|
||
|
|
||
|
renderBalance () {
|
||
6 years ago
|
const { selectedToken, balance } = this.props
|
||
6 years ago
|
|
||
|
return selectedToken
|
||
|
? (
|
||
|
<TokenBalance
|
||
|
token={selectedToken}
|
||
|
withSymbol
|
||
6 years ago
|
className="transaction-view-balance__token-balance"
|
||
6 years ago
|
/>
|
||
|
) : (
|
||
6 years ago
|
<div className="transaction-view-balance__balance">
|
||
6 years ago
|
<CurrencyDisplay
|
||
6 years ago
|
className="transaction-view-balance__primary-balance"
|
||
6 years ago
|
value={balance}
|
||
|
currency={ETH}
|
||
|
numberOfDecimals={3}
|
||
|
/>
|
||
|
<CurrencyDisplay
|
||
6 years ago
|
className="transaction-view-balance__secondary-balance"
|
||
6 years ago
|
value={balance}
|
||
|
/>
|
||
6 years ago
|
</div>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
renderButtons () {
|
||
|
const { t } = this.context
|
||
|
const { selectedToken, showDepositModal, history } = this.props
|
||
|
|
||
|
return (
|
||
6 years ago
|
<div className="transaction-view-balance__buttons">
|
||
6 years ago
|
{
|
||
|
!selectedToken && (
|
||
|
<Button
|
||
|
type="primary"
|
||
6 years ago
|
className="transaction-view-balance__button"
|
||
6 years ago
|
onClick={() => showDepositModal()}
|
||
|
>
|
||
|
{ t('deposit') }
|
||
|
</Button>
|
||
|
)
|
||
|
}
|
||
|
<Button
|
||
|
type="primary"
|
||
6 years ago
|
className="transaction-view-balance__button"
|
||
6 years ago
|
onClick={() => history.push(SEND_ROUTE)}
|
||
|
>
|
||
|
{ t('send') }
|
||
|
</Button>
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
render () {
|
||
|
const { network, selectedToken } = this.props
|
||
|
|
||
|
return (
|
||
6 years ago
|
<div className="transaction-view-balance">
|
||
|
<div className="transaction-view-balance__balance-container">
|
||
6 years ago
|
<Identicon
|
||
|
diameter={50}
|
||
|
address={selectedToken && selectedToken.address}
|
||
|
network={network}
|
||
|
/>
|
||
|
{ this.renderBalance() }
|
||
|
</div>
|
||
|
{ this.renderButtons() }
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
}
|