From 91522bc4d940c3665ac850e4225bbf75d722cdab Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 29 Sep 2021 17:58:22 +1000 Subject: [PATCH] Re-work use of `Skeleton` to hide the content we are loading Destructing the nullable object into its fields gives us an opportunity to assign an empty object instead (via `||`). --- frontend/src/components/CurrentPrice.tsx | 22 ++++++------- frontend/src/components/Wallet.tsx | 39 +++++++++++------------- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/frontend/src/components/CurrentPrice.tsx b/frontend/src/components/CurrentPrice.tsx index 9f5ede7..1f754ab 100644 --- a/frontend/src/components/CurrentPrice.tsx +++ b/frontend/src/components/CurrentPrice.tsx @@ -12,32 +12,30 @@ export default function CurrentPrice( priceInfo, }: Props, ) { - let bid = ; - let ask = ; - let timestamp = ; - - if (priceInfo) { - bid = {priceInfo.bid} USD; - ask = {priceInfo.ask} USD; - timestamp = ; - } + const { ask, bid, last_updated_at } = priceInfo || {}; return (
Current Price
Bid: - {bid} + + {bid} USD + Ask: - {ask} + + {ask} USD + Updated: - {timestamp} + + +
); diff --git a/frontend/src/components/Wallet.tsx b/frontend/src/components/Wallet.tsx index e62a59a..19ff5ba 100644 --- a/frontend/src/components/Wallet.tsx +++ b/frontend/src/components/Wallet.tsx @@ -14,39 +14,34 @@ export default function Wallet( }: WalletProps, ) { const { hasCopied, onCopy } = useClipboard(walletInfo ? walletInfo.address : ""); - - let balance = ; - let address = ; - let timestamp = ; - - if (walletInfo) { - balance = {walletInfo.balance} BTC; - address = ( - - {walletInfo.address} - : } - onClick={onCopy} - /> - - ); - timestamp = ; - } + const { balance, address, last_updated_at } = walletInfo || {}; return (
Your wallet
Balance: - {balance} + + {balance} BTC + - {address} + + + {address} + : } + onClick={onCopy} + /> + + Updated: - {timestamp} + + +
);