From 858c181adab65d17c7f2d2ab00b39c5271fcef33 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 29 Sep 2021 17:56:20 +1000 Subject: [PATCH 1/2] Remove `Updated:` label from timestamp component This makes it more composable by not forcing the label onto the user of the component. --- frontend/src/components/CurrentPrice.tsx | 5 ++++- frontend/src/components/Timestamp.tsx | 2 +- frontend/src/components/Wallet.tsx | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/CurrentPrice.tsx b/frontend/src/components/CurrentPrice.tsx index fa94833..9f5ede7 100644 --- a/frontend/src/components/CurrentPrice.tsx +++ b/frontend/src/components/CurrentPrice.tsx @@ -35,7 +35,10 @@ export default function CurrentPrice( {ask} - {timestamp} + + Updated: + {timestamp} + ); } diff --git a/frontend/src/components/Timestamp.tsx b/frontend/src/components/Timestamp.tsx index a3709aa..cf46e31 100644 --- a/frontend/src/components/Timestamp.tsx +++ b/frontend/src/components/Timestamp.tsx @@ -13,7 +13,7 @@ export default function Timestamp( ) { return ( - Updated: {unixTimestampToDate(timestamp).toLocaleDateString("en-US", { + {unixTimestampToDate(timestamp).toLocaleDateString("en-US", { year: "numeric", month: "numeric", day: "numeric", diff --git a/frontend/src/components/Wallet.tsx b/frontend/src/components/Wallet.tsx index 209beba..e62a59a 100644 --- a/frontend/src/components/Wallet.tsx +++ b/frontend/src/components/Wallet.tsx @@ -44,7 +44,10 @@ export default function Wallet( {address} - {timestamp} + + Updated: + {timestamp} + ); } From 91522bc4d940c3665ac850e4225bbf75d722cdab Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 29 Sep 2021 17:58:22 +1000 Subject: [PATCH 2/2] 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} + + +
);