Skip to content

Commit

Permalink
format reward amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoseneca committed Mar 25, 2024
1 parent 80fdbb8 commit de41c9d
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Swiper, SwiperRef, SwiperSlide } from 'swiper/react';
import useAssetsWithMetadata, { AssetWithMetadata } from '../../hooks/useAssetsWithMetadata';
import buildEtherscanPath from '../../utils/buildEtherscanPath';
import buildOpenSeaPath from '../../utils/buildOpenSeaPath';
import { truncateThousands } from '../../utils/truncateThousands';
import Skeleton from 'react-loading-skeleton';

const RoundAwardsDisplay: React.FC<{
Expand Down Expand Up @@ -45,6 +44,17 @@ const RoundAwardsDisplay: React.FC<{
];
};

const formatRewardAmount = (num: number) =>
num >= 1000000
? (num / 1000000).toFixed(0) + 'M'
: num >= 10000
? (num / 1000).toFixed(0) + 'K'
: num >= 1000
? (num / 1000).toFixed(1) + 'K'
: num >= 1
? num.toFixed(0).toString()
: num.toFixed(4).toString();

const sliderRef = useRef<SwiperRef>(null);
const [loadingAssetsWithMetadata, assetsWithMetadata] = useAssetsWithMetadata(longAwardsFix());

Expand Down Expand Up @@ -111,10 +121,7 @@ const RoundAwardsDisplay: React.FC<{
</>
) : (
<>
{award.parsedAmount > 1000
? truncateThousands(award.parsedAmount)
: award.parsedAmount}{' '}
{award.symbol}
{formatRewardAmount(award.parsedAmount)} {award.symbol}
</>
)}
</div>
Expand Down

0 comments on commit de41c9d

Please sign in to comment.