Skip to content

Commit

Permalink
Landing table - fix negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
manishiwa committed Oct 22, 2024
1 parent c77d655 commit 0231762
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/layout/LandingMetricsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ const ChainRankCell = memo(function ChainRankIcon(
let rawValue = values[types.indexOf(valueKey)];
let isNegative = rawValue < 0;
let value = formatNumber(Math.abs(rawValue), decimals);
let absoluteValue = formatNumber(Math.abs(rawValue), decimals);

if (types.includes("value_eth")) {
if (!showUsd) {
Expand All @@ -413,12 +414,20 @@ const ChainRankCell = memo(function ChainRankIcon(
values[types.indexOf("value_eth")] * 1000000000,
decimals,
);
absoluteValue = formatNumber(
Math.abs(values[types.indexOf("value_eth")]) * 1000000000,
decimals,
);
}
} else {
value = formatNumber(values[types.indexOf("value_usd")], decimals);
absoluteValue = formatNumber(
Math.abs(values[types.indexOf("value_usd")]),
decimals,
);
}
}
return { value, prefix, suffix, isNegative };
return { value, prefix, suffix, isNegative, absoluteValue };
},
[master, showGwei, showUsd],
);
Expand Down Expand Up @@ -508,7 +517,7 @@ const ChainRankCell = memo(function ChainRankIcon(
{getDisplayValue(metric, values, valueKeys).prefix}
</div>
)}
{getDisplayValue(metric, values, valueKeys).value}
{getDisplayValue(metric, values, valueKeys).absoluteValue}
{getDisplayValue(metric, values, valueKeys).suffix && (
<div className="pl-[5px] font-raleway">
{getDisplayValue(metric, values, valueKeys).suffix}
Expand Down

0 comments on commit 0231762

Please sign in to comment.