From 16ecb93ec0ec807369bb328ab573827c97fb2e3f Mon Sep 17 00:00:00 2001 From: Bal7hazar Date: Tue, 17 Dec 2024 21:51:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Add=20delimiter=20(#1174)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 Add delimiter * 📱 Improve design --- .../src/components/inventory/token/send.tsx | 34 ++++++++++++++++--- .../src/components/inventory/token/token.tsx | 19 +++++++++-- .../src/components/inventory/token/tokens.tsx | 25 +++++++++++--- 3 files changed, 66 insertions(+), 12 deletions(-) diff --git a/packages/profile/src/components/inventory/token/send.tsx b/packages/profile/src/components/inventory/token/send.tsx index 274a868ac..7b983bbeb 100644 --- a/packages/profile/src/components/inventory/token/send.tsx +++ b/packages/profile/src/components/inventory/token/send.tsx @@ -112,6 +112,21 @@ export function SendToken() { { enabled: t && ["ETH", "STRK"].includes(t.meta.symbol) && !!amount }, ); + const countervalueFormatted = useMemo(() => { + if (!countervalue) return undefined; + // Catch prefix until number + let prefix = ""; + for (const char of countervalue.formatted) { + if (!isNaN(parseInt(char))) { + break; + } + prefix += char; + } + return `${prefix}${parseFloat( + countervalue.formatted.replace(prefix, ""), + ).toLocaleString()}`; + }, [countervalue]); + if (!t) { return null; } @@ -127,7 +142,7 @@ export function SendToken() { } > } icon={ Amount
Balance: -
- {t.balance.formatted} {t.meta.symbol} +
+ form.setValue( + "amount", + parseFloat(t.balance.formatted), + ) + } + > + {parseFloat(t.balance.formatted).toLocaleString()}{" "} + {t.meta.symbol}
@@ -171,14 +195,14 @@ export function SendToken() {
{countervalue && ( - {countervalue.formatted} + {countervalueFormatted} )}
diff --git a/packages/profile/src/components/inventory/token/token.tsx b/packages/profile/src/components/inventory/token/token.tsx index 78e762e2c..f2d850815 100644 --- a/packages/profile/src/components/inventory/token/token.tsx +++ b/packages/profile/src/components/inventory/token/token.tsx @@ -106,6 +106,21 @@ function ERC20() { { enabled: t && ["ETH", "STRK"].includes(t.meta.symbol) }, ); + const countervalueFormatted = useMemo(() => { + if (!countervalue) return undefined; + // Catch prefix until number + let prefix = ""; + for (const char of countervalue.formatted) { + if (!isNaN(parseInt(char))) { + break; + } + prefix += char; + } + return `${prefix}${parseFloat( + countervalue.formatted.replace(prefix, ""), + ).toLocaleString()}`; + }, [countervalue]); + const compatibility = useMemo(() => { if (!version) return false; return compare(version, "0.4.0", ">="); @@ -130,10 +145,10 @@ function ERC20() { t.balance === undefined ? ( ) : ( - t.balance.formatted + parseFloat(t.balance.formatted).toLocaleString() ) } ${t.meta.symbol}`} - description={countervalue && `${countervalue.formatted} (USD)`} + description={countervalueFormatted && `$${countervalueFormatted} (USD)`} icon={ { + if (!countervalue) return undefined; + // Catch prefix until number + let prefix = ""; + for (const char of countervalue.formatted) { + if (!isNaN(parseInt(char))) { + break; + } + prefix += char; + } + return `${prefix}${parseFloat( + countervalue.formatted.replace(prefix, ""), + ).toLocaleString()}`; + }, [countervalue]); + return (
-
{token.balance.formatted}
-
{token.meta.symbol}
+

{parseFloat(token.balance.formatted).toLocaleString()}

+ {token.meta.symbol}
- {countervalue && ( -
{countervalue.formatted}
+ {countervalueFormatted && ( + {countervalueFormatted} )}