2021-06-09 15:11:37 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2021-06-09 15:11:37 -07:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-02-02 05:33:12 -08:00
|
|
|
import { openModal } from 'soapbox/actions/modals';
|
2022-01-10 14:17:52 -08:00
|
|
|
import Icon from 'soapbox/components/icon';
|
2021-06-09 17:49:53 -07:00
|
|
|
import { CopyableInput } from 'soapbox/features/forms';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-06-09 17:49:53 -07:00
|
|
|
import { getExplorerUrl } from '../utils/block_explorer';
|
2022-01-10 14:17:52 -08:00
|
|
|
import CoinDB from '../utils/coin_db';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import CryptoIcon from './crypto_icon';
|
2021-06-09 16:28:54 -07:00
|
|
|
|
2021-06-09 17:28:16 -07:00
|
|
|
export default @connect()
|
|
|
|
class CryptoAddress extends ImmutablePureComponent {
|
2021-06-09 15:11:37 -07:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
address: PropTypes.string.isRequired,
|
|
|
|
ticker: PropTypes.string.isRequired,
|
|
|
|
note: PropTypes.string,
|
|
|
|
}
|
|
|
|
|
2021-06-09 17:28:16 -07:00
|
|
|
handleModalClick = e => {
|
|
|
|
this.props.dispatch(openModal('CRYPTO_DONATE', this.props));
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
2021-06-09 15:11:37 -07:00
|
|
|
render() {
|
|
|
|
const { address, ticker, note } = this.props;
|
|
|
|
const title = CoinDB.getIn([ticker, 'name']);
|
2021-06-09 16:28:54 -07:00
|
|
|
const explorerUrl = getExplorerUrl(ticker, address);
|
2021-06-09 15:11:37 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='crypto-address'>
|
2021-06-09 15:55:28 -07:00
|
|
|
<div className='crypto-address__head'>
|
2021-09-11 14:21:12 -07:00
|
|
|
<CryptoIcon
|
|
|
|
className='crypto-address__icon'
|
|
|
|
ticker={ticker}
|
|
|
|
title={title}
|
|
|
|
/>
|
2021-06-09 18:36:02 -07:00
|
|
|
<div className='crypto-address__title'>{title || ticker.toUpperCase()}</div>
|
2021-06-09 16:28:54 -07:00
|
|
|
<div className='crypto-address__actions'>
|
2021-06-09 17:28:16 -07:00
|
|
|
<a href='' onClick={this.handleModalClick}>
|
2021-09-27 21:47:43 -07:00
|
|
|
<Icon src={require('@tabler/icons/icons/qrcode.svg')} />
|
2021-06-09 17:28:16 -07:00
|
|
|
</a>
|
2021-06-09 18:36:02 -07:00
|
|
|
{explorerUrl && <a href={explorerUrl} target='_blank'>
|
2021-09-27 21:47:43 -07:00
|
|
|
<Icon src={require('@tabler/icons/icons/external-link.svg')} />
|
2021-06-09 18:36:02 -07:00
|
|
|
</a>}
|
2021-06-09 16:28:54 -07:00
|
|
|
</div>
|
2021-06-09 15:11:37 -07:00
|
|
|
</div>
|
|
|
|
{note && <div className='crypto-address__note'>{note}</div>}
|
2021-06-09 16:53:13 -07:00
|
|
|
<div className='crypto-address__address simple_form'>
|
2021-06-09 17:49:53 -07:00
|
|
|
<CopyableInput value={address} />
|
2021-06-09 15:39:45 -07:00
|
|
|
</div>
|
2021-06-09 15:11:37 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|