2020-07-06 13:56:15 -07:00
|
|
|
import React from 'react'
|
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import { Row, Col, Box, Button } from 'adminlte-2-react'
|
|
|
|
|
import Jdenticon from 'react-jdenticon'
|
|
|
|
|
import './token.css'
|
2020-06-27 00:12:07 -04:00
|
|
|
let _this
|
|
|
|
|
class TokenCard extends React.Component {
|
2020-07-06 13:56:15 -07:00
|
|
|
constructor (props) {
|
2020-06-27 00:12:07 -04:00
|
|
|
super(props)
|
|
|
|
|
_this = this
|
|
|
|
|
this.state = {}
|
|
|
|
|
}
|
2020-07-06 13:56:15 -07:00
|
|
|
|
|
|
|
|
render () {
|
2020-06-27 00:12:07 -04:00
|
|
|
const token = _this.props.token
|
2021-04-07 11:11:20 -07:00
|
|
|
// console.log(`token: ${JSON.stringify(token, null, 2)}`)
|
2021-02-24 19:35:52 -08:00
|
|
|
|
2020-06-27 00:12:07 -04:00
|
|
|
return (
|
|
|
|
|
<>
|
2020-07-06 13:56:15 -07:00
|
|
|
<Box className='hover-shadow border-none mt-2' id='token-card'>
|
|
|
|
|
<Row className='text-center'>
|
|
|
|
|
<Col sm={12} className='text-center mt-2 '>
|
|
|
|
|
<Jdenticon size='100' value={token.tokenId} />
|
|
|
|
|
<hr />
|
2020-06-27 00:12:07 -04:00
|
|
|
</Col>
|
2020-07-06 13:56:15 -07:00
|
|
|
<Col sm={12} className='flex justify-content-center '>
|
|
|
|
|
<div className='info-container'>
|
|
|
|
|
<p className='info-content'>
|
2020-06-27 00:12:07 -04:00
|
|
|
<b>Ticker: </b>
|
|
|
|
|
<span> {token.ticker}</span>
|
|
|
|
|
</p>
|
2020-07-06 13:56:15 -07:00
|
|
|
<p className='info-content'>
|
2020-06-27 00:12:07 -04:00
|
|
|
<b>Name: </b>
|
|
|
|
|
<span>{token.name}</span>
|
|
|
|
|
</p>
|
|
|
|
|
|
2020-07-06 13:56:15 -07:00
|
|
|
<p className='info-content'>
|
2020-06-27 00:12:07 -04:00
|
|
|
<b>Balance</b>
|
2020-10-25 20:39:24 -03:00
|
|
|
<span>{_this.round(token.qty, token.decimals)}</span>
|
2020-06-27 00:12:07 -04:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</Col>
|
|
|
|
|
|
2020-07-07 06:06:30 -04:00
|
|
|
<Col xs={6} className='text-center mb-1'>
|
2020-06-27 00:12:07 -04:00
|
|
|
<Button
|
2020-07-07 06:06:30 -04:00
|
|
|
text='Info'
|
2020-07-06 13:56:15 -07:00
|
|
|
type='primary'
|
2020-07-07 06:06:30 -04:00
|
|
|
className='btn-lg max-width'
|
2020-06-27 00:12:07 -04:00
|
|
|
onClick={() => {
|
|
|
|
|
_this.props.showToken(token)
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Col>
|
2020-07-07 06:06:30 -04:00
|
|
|
<Col xs={6} className='text-center'>
|
|
|
|
|
<Button
|
|
|
|
|
text='Send'
|
|
|
|
|
type='primary'
|
|
|
|
|
className='btn-lg max-width'
|
|
|
|
|
onClick={() => {
|
|
|
|
|
_this.props.selectToken(token)
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Col>
|
2020-06-27 00:12:07 -04:00
|
|
|
</Row>
|
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
2020-07-06 13:56:15 -07:00
|
|
|
|
|
|
|
|
shouldComponentUpdate () {
|
2020-06-27 00:12:07 -04:00
|
|
|
return false
|
|
|
|
|
}
|
2020-10-25 20:39:24 -03:00
|
|
|
|
|
|
|
|
round (value, decimals) {
|
2020-10-25 20:40:03 -03:00
|
|
|
return Number(Math.round(value + `e${decimals}`) + `e-${decimals}`)
|
2020-10-25 20:39:24 -03:00
|
|
|
}
|
2020-06-27 00:12:07 -04:00
|
|
|
}
|
|
|
|
|
TokenCard.propTypes = {
|
|
|
|
|
token: PropTypes.object.isRequired,
|
2020-07-07 06:06:30 -04:00
|
|
|
showToken: PropTypes.func.isRequired,
|
|
|
|
|
selectToken: PropTypes.func.isRequired
|
2020-06-27 00:12:07 -04:00
|
|
|
}
|
|
|
|
|
export default TokenCard
|