Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
olehkhalin committed Aug 11, 2022
1 parent dd655b4 commit 88e99e4
Showing 1 changed file with 14 additions and 32 deletions.
46 changes: 14 additions & 32 deletions src/app/components/elements/PrettyAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const PrettyAmount = memo<PrettyAmountProps>(
integerPart.toString().length >
(isMinified && isThousandsMinified ? 3 : 6);

const zeroDecimals =
!isFiat && decimals === 0 && new BigNumber(amount ?? 0).isInteger();

let tooltipContent = getPrettyAmount({
value: isFiatMinified
? convertedAmount.decimalPlaces(
Expand All @@ -82,12 +85,7 @@ const PrettyAmount = memo<PrettyAmountProps>(
: BigNumber.ROUND_UP
)
: convertedAmount,
dec:
!isFiat && decimals === 0
? 0
: isMinified && isThousandsMinified
? 3
: undefined,
dec: zeroDecimals ? 0 : isMinified && isThousandsMinified ? 3 : undefined,
locale: currentLocale,
isFiat,
currency,
Expand All @@ -101,12 +99,7 @@ const PrettyAmount = memo<PrettyAmountProps>(
: BigNumber.ROUND_UP
)
: convertedAmount,
dec:
!isFiat && decimals === 0
? 0
: isMinified && isThousandsMinified
? 3
: undefined,
dec: zeroDecimals ? 0 : isMinified && isThousandsMinified ? 3 : undefined,
locale: currentLocale,
useGrouping: false,
isDecimalsMinified,
Expand All @@ -120,12 +113,7 @@ const PrettyAmount = memo<PrettyAmountProps>(
: BigNumber.ROUND_UP
)
: convertedAmount,
dec:
!isFiat && decimals === 0
? 0
: isMinified && isThousandsMinified
? 3
: undefined,
dec: zeroDecimals ? 0 : isMinified && isThousandsMinified ? 3 : undefined,
locale: currentLocale,
isFiat,
currency,
Expand All @@ -135,12 +123,7 @@ const PrettyAmount = memo<PrettyAmountProps>(
if (isShownIntTooltip) {
content = getPrettyAmount({
value: convertedAmount,
dec:
!isFiat && decimals === 0
? 0
: isMinified && isThousandsMinified
? 3
: 6,
dec: zeroDecimals ? 0 : isMinified && isThousandsMinified ? 3 : 6,
locale: currentLocale,
isFiat,
currency,
Expand All @@ -151,7 +134,7 @@ const PrettyAmount = memo<PrettyAmountProps>(
value: isFiatMinified
? convertedAmount.decimalPlaces(2, BigNumber.ROUND_DOWN)
: convertedAmount,
dec: !isFiat && decimals === 0 ? 0 : 38,
dec: zeroDecimals ? 0 : 38,
locale: currentLocale,
isFiat,
currency,
Expand All @@ -161,7 +144,7 @@ const PrettyAmount = memo<PrettyAmountProps>(
value: isFiatMinified
? convertedAmount.decimalPlaces(2, BigNumber.ROUND_DOWN)
: convertedAmount,
dec: !isFiat && decimals === 0 ? 0 : 38,
dec: zeroDecimals ? 0 : 38,
locale: currentLocale,
useGrouping: false,
isDecimalsMinified,
Expand All @@ -174,12 +157,11 @@ const PrettyAmount = memo<PrettyAmountProps>(
isFiatDecimalsMinified ? 2 : decSplit,
isFiatDecimalsMinified ? BigNumber.ROUND_UP : BigNumber.ROUND_DOWN
),
dec:
decimals === 0
? 0
: isMinified && isThousandsMinified
? 3
: undefined,
dec: zeroDecimals
? 0
: isMinified && isThousandsMinified
? 3
: undefined,
locale: currentLocale,
threeDots,
isFiat,
Expand Down

0 comments on commit 88e99e4

Please sign in to comment.