2022-03-25 14:55:48 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
|
|
|
import { openModal } from 'soapbox/actions/modals';
|
2022-08-25 19:23:17 -07:00
|
|
|
import CopyableInput from 'soapbox/components/copyable-input';
|
2022-03-25 15:47:19 -07:00
|
|
|
import { Text, Icon, Stack, HStack } from 'soapbox/components/ui';
|
2022-03-25 14:55:48 -07:00
|
|
|
|
2022-11-15 09:23:36 -08:00
|
|
|
import { getExplorerUrl } from '../utils/block-explorer';
|
|
|
|
import { getTitle } from '../utils/coin-db';
|
2022-03-25 14:55:48 -07:00
|
|
|
|
2022-11-15 09:23:36 -08:00
|
|
|
import CryptoIcon from './crypto-icon';
|
2022-03-25 14:55:48 -07:00
|
|
|
|
2022-06-12 07:14:46 -07:00
|
|
|
export interface ICryptoAddress {
|
2022-03-25 14:55:48 -07:00
|
|
|
address: string,
|
|
|
|
ticker: string,
|
|
|
|
note?: string,
|
|
|
|
}
|
|
|
|
|
|
|
|
const CryptoAddress: React.FC<ICryptoAddress> = (props): JSX.Element => {
|
|
|
|
const { address, ticker, note } = props;
|
|
|
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
const handleModalClick = (e: React.MouseEvent<HTMLElement>): void => {
|
|
|
|
dispatch(openModal('CRYPTO_DONATE', props));
|
|
|
|
e.preventDefault();
|
|
|
|
};
|
|
|
|
|
|
|
|
const title = getTitle(ticker);
|
|
|
|
const explorerUrl = getExplorerUrl(ticker, address);
|
|
|
|
|
|
|
|
return (
|
2022-03-25 15:47:19 -07:00
|
|
|
<Stack>
|
|
|
|
<HStack alignItems='center' className='mb-1'>
|
2022-03-25 14:55:48 -07:00
|
|
|
<CryptoIcon
|
2022-11-25 09:04:11 -08:00
|
|
|
className='flex items-start justify-center w-6 mr-2.5 rtl:ml-2.5 rtl:mr-0'
|
2022-03-25 14:55:48 -07:00
|
|
|
ticker={ticker}
|
|
|
|
title={title}
|
|
|
|
/>
|
2022-03-25 15:47:19 -07:00
|
|
|
|
|
|
|
<Text weight='bold'>{title || ticker.toUpperCase()}</Text>
|
|
|
|
|
|
|
|
<HStack alignItems='center' className='ml-auto'>
|
2022-11-25 09:04:11 -08:00
|
|
|
<a className='text-gray-500 ml-1 rtl:ml-0 rtl:mr-1' href='#' onClick={handleModalClick}>
|
2022-07-09 09:20:02 -07:00
|
|
|
<Icon src={require('@tabler/icons/qrcode.svg')} size={20} />
|
2022-03-25 14:55:48 -07:00
|
|
|
</a>
|
2022-03-25 15:47:19 -07:00
|
|
|
|
|
|
|
{explorerUrl && (
|
2022-11-25 09:04:11 -08:00
|
|
|
<a className='text-gray-500 ml-1 rtl:ml-0 rtl:mr-1' href={explorerUrl} target='_blank'>
|
2022-07-09 09:20:02 -07:00
|
|
|
<Icon src={require('@tabler/icons/external-link.svg')} size={20} />
|
2022-03-25 15:47:19 -07:00
|
|
|
</a>
|
|
|
|
)}
|
|
|
|
</HStack>
|
|
|
|
</HStack>
|
|
|
|
|
|
|
|
{note && (
|
|
|
|
<Text>{note}</Text>
|
|
|
|
)}
|
|
|
|
|
2022-08-25 19:23:17 -07:00
|
|
|
<CopyableInput value={address} />
|
2022-03-25 15:47:19 -07:00
|
|
|
</Stack>
|
2022-03-25 14:55:48 -07:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CryptoAddress;
|