Skip to content

Commit

Permalink
Merge pull request #3161 from CrocSwap/fix-ellipsis-bug-for-usd-value
Browse files Browse the repository at this point in the history
fix ellipsis bug for usd token input value
  • Loading branch information
benwolski authored Oct 27, 2023
2 parents 01ef4b6 + 2e6f55d commit 00725cc
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/components/Form/TokenInputWithWalletBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,20 @@ function TokenInputWithWalletBalance(props: propsIF) {
Promise.resolve(cachedFetchTokenPrice(pricedToken, chainId)).then(
(price) => {
if (price?.usdPrice !== undefined) {
const usdValueNum: number =
(price &&
price?.usdPrice * (parseFloat(tokenInput) ?? 0)) ??
0;
const usdValueTruncated = getFormattedNumber({
value: usdValueNum,
isUSD: true,
});
setUsdValueForDom(usdValueTruncated);
const usdValueNum: number | undefined =
price !== undefined && tokenInput !== ''
? price.usdPrice * parseFloat(tokenInput)
: undefined;
const usdValueTruncated =
usdValueNum !== undefined
? getFormattedNumber({
value: usdValueNum,
isUSD: true,
})
: undefined;
usdValueTruncated !== undefined
? setUsdValueForDom(usdValueTruncated)
: setUsdValueForDom('');
} else {
setUsdValueForDom(undefined);
}
Expand Down

0 comments on commit 00725cc

Please sign in to comment.