From 18323cdc75834e9e8c47d96fda16302c7be43907 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 25 Mar 2022 16:55:48 -0500 Subject: [PATCH] CryptoAddress: convert to tsx --- .../components/crypto_address.js | Bin 1904 -> 0 bytes .../components/crypto_address.tsx | 58 ++++++++++++++++++ .../components/detailed_crypto_address.tsx | 7 +-- .../crypto_donate/components/site_wallet.tsx | 4 +- .../features/crypto_donate/utils/coin_db.ts | 6 ++ 5 files changed, 68 insertions(+), 7 deletions(-) delete mode 100644 app/soapbox/features/crypto_donate/components/crypto_address.js create mode 100644 app/soapbox/features/crypto_donate/components/crypto_address.tsx diff --git a/app/soapbox/features/crypto_donate/components/crypto_address.js b/app/soapbox/features/crypto_donate/components/crypto_address.js deleted file mode 100644 index d3115853eaa7312005a864b70cf9d2db5cd332e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1904 zcmb7F%Wm5+5WM><_EgD0EZrL`Nb2O^Lz5s#4ng}(3fD7ZH=^?i^Oy%p3KPzi{oNlece~n<6{q*L zq6>+5LB$9=V;y8xA!b%|pq`|GLJC1KM?1_iQ?#rP2 zObVUu?CC)J5~%}e2R$m#DZ|sDj)kmVZ8b|#)xDZ7a7~H95_GzjYG-rw!k($QIaFLK zs-9G@E=khbFs{=Tm&G=x0n(>jNG7g-1c66%fxCIR8e~|g*UHF2F-cmutvr-4L2f(G zlCDY34P1tn#?wi`iPqp5uF4V%&_EA{ic-Tn^J^v(0Bwk21z1OThh)&;HURM?-+S{U z+9)QT6Q&>NOU-a_XAX(+TdKYQ6w=UtVV0z|QZ_`CoVv*`IC4S;6tat;$84BRtW2Gh zOjpDdoA~III9fdXx_`XOukUWJ9&e&E=;71pxsypTn(ooK*S>qP+jp52wu!2E8d70b zwSlH<0g|~2&%hRdrpyNHp4&$lW;iMaKko$XvJ~;}E;tfoN25PMjgRQOV(pZ{*k5rM z7$$*%t`0@fp8{gH0GO9-4{rLm$e%^tF|!a9T?E)?z&zhjQV!r4(EIU7Vx94BvfTT0 z1olN_jsLbMXV@=$grDI_+Kc{Nwu_D~JPW+Ng<&N|K2;S}3!-T}ZRaVr>3?X$Q!{D^ ziXpI3be%;JNa0M1@~tsXz1t3R*{03iwbrW08s%?K99_CcRk;VsKT|q=QH3mNqW90y zw1rV8kR&Bz-ezc^Z{LpkhWjlTqR?7dl&?4u+mn*MF3mnCN)SHdOl&_;I2`3k-%pl} zyHHm5hbGQ*i^Cb)PZ(vN = (props): JSX.Element => { + const { address, ticker, note } = props; + + const dispatch = useDispatch(); + + const handleModalClick = (e: React.MouseEvent): void => { + dispatch(openModal('CRYPTO_DONATE', props)); + e.preventDefault(); + }; + + const title = getTitle(ticker); + const explorerUrl = getExplorerUrl(ticker, address); + + return ( +
+
+ +
{title || ticker.toUpperCase()}
+
+ + + + {explorerUrl && + + } +
+
+ {note &&
{note}
} +
+ +
+
+ ); +}; + +export default CryptoAddress; diff --git a/app/soapbox/features/crypto_donate/components/detailed_crypto_address.tsx b/app/soapbox/features/crypto_donate/components/detailed_crypto_address.tsx index 7d58d4e330..053ea16c7f 100644 --- a/app/soapbox/features/crypto_donate/components/detailed_crypto_address.tsx +++ b/app/soapbox/features/crypto_donate/components/detailed_crypto_address.tsx @@ -5,7 +5,7 @@ import Icon from 'soapbox/components/icon'; import { CopyableInput } from 'soapbox/features/forms'; import { getExplorerUrl } from '../utils/block_explorer'; -import CoinDB from '../utils/coin_db'; +import { getTitle } from '../utils/coin_db'; import CryptoIcon from './crypto_icon'; @@ -15,11 +15,6 @@ interface IDetailedCryptoAddress { note?: string, } -const getTitle = (ticker: string): string => { - const title = CoinDB.getIn([ticker, 'name']); - return typeof title === 'string' ? title : ''; -}; - const DetailedCryptoAddress: React.FC = ({ address, ticker, note }): JSX.Element => { const title = getTitle(ticker); const explorerUrl = getExplorerUrl(ticker, address); diff --git a/app/soapbox/features/crypto_donate/components/site_wallet.tsx b/app/soapbox/features/crypto_donate/components/site_wallet.tsx index 062f9f78dd..4814d8342c 100644 --- a/app/soapbox/features/crypto_donate/components/site_wallet.tsx +++ b/app/soapbox/features/crypto_donate/components/site_wallet.tsx @@ -32,7 +32,9 @@ const SiteWallet: React.FC = ({ limit }): JSX.Element => { {coinList.map(coin => ( ))} diff --git a/app/soapbox/features/crypto_donate/utils/coin_db.ts b/app/soapbox/features/crypto_donate/utils/coin_db.ts index 3ca2d3a18c..582ace540b 100644 --- a/app/soapbox/features/crypto_donate/utils/coin_db.ts +++ b/app/soapbox/features/crypto_donate/utils/coin_db.ts @@ -5,3 +5,9 @@ import manifestMap from './manifest_map'; // All this does is converts the result from manifest_map.js into an ImmutableMap const coinDB = fromJS(manifestMap); export default coinDB; + +/** Get title from CoinDB based on ticker symbol */ +export const getTitle = (ticker: string): string => { + const title = coinDB.getIn([ticker, 'name']); + return typeof title === 'string' ? title : ''; +};