Skip to content

Commit

Permalink
Merge pull request #228 from pastelnetwork/feature/update-format-number
Browse files Browse the repository at this point in the history
Changed the format number of Network
  • Loading branch information
Dicklesworthstone authored May 30, 2024
2 parents 7c928c0 + 3bac9c8 commit 5225729
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/components/Summary/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,31 @@ const Summary: React.FC = () => {
const key = summaryElement.key as keyof ISummaryStats;
const currentVal = currentStats?.[key] || 0;
const lastDayStatsVal = lastDayStats?.[key] || 0;
let value = formatNumber(
summaryElement.key === 'percentPSLStaked'
? parseFloat(currentVal.toString()) * 100
: currentVal,
{
decimalsLength: summaryElement.decimals,
divideToAmount: summaryElement.divideToAmount,
},
);
let previousValue = formatNumber(
summaryElement.key === 'percentPSLStaked'
? parseFloat(lastDayStatsVal.toString()) * 100
: lastDayStatsVal,
{
decimalsLength: summaryElement.decimals,
},
);
if (summaryElement.key === 'gigaHashPerSec') {
value = currentVal.toString();
previousValue = lastDayStatsVal.toString();
}
return {
...summaryElement,
value: formatNumber(
summaryElement.key === 'percentPSLStaked'
? parseFloat(currentVal.toString()) * 100
: currentVal,
{
decimalsLength: summaryElement.decimals,
divideToAmount: summaryElement.divideToAmount,
},
),
previousValue: formatNumber(
summaryElement.key === 'percentPSLStaked'
? parseFloat(lastDayStatsVal.toString()) * 100
: lastDayStatsVal,
{
decimalsLength: summaryElement.decimals,
},
),
value,
previousValue,
difference: calculateDifference(
Number(currentStats?.[key]) || 0,
Number(lastDayStats?.[key]) || 0,
Expand Down

0 comments on commit 5225729

Please sign in to comment.