pleroma/app/soapbox/features/crypto_donate/components/detailed_crypto_address.js

51 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-06-09 17:28:16 -07:00
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import ImmutablePureComponent from 'react-immutable-pure-component';
import Icon from 'soapbox/components/icon';
import QRCode from 'qrcode.react';
import CoinDB from '../utils/coin_db';
import { getCoinIcon } from '../utils/coin_icons';
2021-06-09 17:49:53 -07:00
import { CopyableInput } from 'soapbox/features/forms';
import { getExplorerUrl } from '../utils/block_explorer';
2021-06-09 17:28:16 -07:00
export default @connect()
class DetailedCryptoAddress extends ImmutablePureComponent {
static propTypes = {
address: PropTypes.string.isRequired,
ticker: PropTypes.string.isRequired,
note: PropTypes.string,
}
render() {
const { address, ticker, note } = this.props;
const title = CoinDB.getIn([ticker, 'name']);
const explorerUrl = getExplorerUrl(ticker, address);
return (
<div className='crypto-address'>
<div className='crypto-address__head'>
<div className='crypto-address__icon'>
<img src={getCoinIcon(ticker)} alt={title} />
</div>
<div className='crypto-address__title'>{title || ticker.toUpperCase()}</div>
2021-06-09 17:28:16 -07:00
<div className='crypto-address__actions'>
{explorerUrl && <a href={explorerUrl} target='_blank'>
2021-06-09 17:28:16 -07:00
<Icon id='external-link' />
</a>}
2021-06-09 17:28:16 -07:00
</div>
</div>
{note && <div className='crypto-address__note'>{note}</div>}
<div className='crypto-address__qrcode'>
<QRCode value={address} />
</div>
<div className='crypto-address__address simple_form'>
2021-06-09 17:49:53 -07:00
<CopyableInput value={address} />
2021-06-09 17:28:16 -07:00
</div>
</div>
);
}
}