Skip to content

Commit

Permalink
update staking labels and format valuers (#1609)
Browse files Browse the repository at this point in the history
* update staking labels and format valuers

* add missing return typr
  • Loading branch information
tomjeatt authored Dec 4, 2023
1 parent 49e3d6a commit e0241cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@
},
"staking_page": {
"stake_ticker": "Stake {{ticker}}",
"total_staked_ticker_in_the_network": "Total Staked {{ticker}} in the network",
"total_ticker_in_the_network": "Total {{ticker}} in the network",
"total_staked_ticker_in_the_network": "Total Staked {{ticker}}",
"total_ticker_in_the_network": "{{ticker}} - Total vote-escrow",
"time": {
"one_week": "1 Week",
"one_month": "1 Month",
Expand Down
11 changes: 11 additions & 0 deletions src/common/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ const formatPercentage = (
return `${format(percentage)}%`;
};

const formatLargeNumber = (amount: number): string => {
const { format } = new Intl.NumberFormat(undefined, {
notation: 'compact',
maximumFractionDigits: 2,
minimumFractionDigits: 2
});

return format(amount);
};

function displayMonetaryAmount(amount: MonetaryAmount<CurrencyExt> | undefined, defaultValue = '0.00'): string {
if (amount === undefined) return defaultValue;

Expand Down Expand Up @@ -194,6 +204,7 @@ export {
displayMonetaryAmountInUSDFormat,
formatDateTime,
formatDateTimePrecise,
formatLargeNumber,
formatNumber,
formatPercentage,
formatUSD,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useTranslation } from 'react-i18next';

import { formatLargeNumber } from '@/common/utils/utils';
import {
TransactionDetails,
TransactionDetailsDd,
Expand Down Expand Up @@ -28,15 +29,15 @@ const StakingNetworkDetails = ({ data, ...props }: StakingNetworkDetailsProps):
{t('staking_page.total_staked_ticker_in_the_network', { ticker: GOVERNANCE_TOKEN.ticker })}
</TransactionDetailsDt>
<TransactionDetailsDd>
{data.totalStakedBalance.toHuman()} {GOVERNANCE_TOKEN.ticker}
{formatLargeNumber(data.totalStakedBalance.toBig().toNumber())} {GOVERNANCE_TOKEN.ticker}
</TransactionDetailsDd>
</TransactionDetailsGroup>
<TransactionDetailsGroup>
<TransactionDetailsDt>
{t('staking_page.total_ticker_in_the_network', { ticker: GOVERNANCE_TOKEN.ticker })}
{t('staking_page.total_ticker_in_the_network', { ticker: VOTE_GOVERNANCE_TOKEN.ticker })}
</TransactionDetailsDt>
<TransactionDetailsDd>
{data.totalVotingSupply.toHuman()} {VOTE_GOVERNANCE_TOKEN.ticker}
{formatLargeNumber(data.totalVotingSupply.toBig().toNumber())} {VOTE_GOVERNANCE_TOKEN.ticker}
</TransactionDetailsDd>
</TransactionDetailsGroup>
</TransactionDetails>
Expand Down

1 comment on commit e0241cd

@vercel
Copy link

@vercel vercel bot commented on e0241cd Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.