Skip to content

Commit 78d9c22

Browse files
committed
Fix TypeError in TotalEarning by properly handling numeric conversions
1 parent 7ffc8c0 commit 78d9c22

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/components/relay-dashboard/totalEarning/TotalEarning.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export const TotalEarning: React.FC = () => {
2828
};
2929
}, [bitcoinRates]);
3030

31-
const latestRate = bitcoinRates.length > 0 ? bitcoinRates[bitcoinRates.length - 1]?.usd_value : undefined;
32-
const previousRate = bitcoinRates.length > 1 ? bitcoinRates[bitcoinRates.length - 2]?.usd_value : undefined;
31+
const latestRate = bitcoinRates.length > 0 ? Number(bitcoinRates[bitcoinRates.length - 1]?.usd_value) : undefined;
32+
const previousRate = bitcoinRates.length > 1 ? Number(bitcoinRates[bitcoinRates.length - 2]?.usd_value) : undefined;
3333
const isIncreased = latestRate && previousRate ? latestRate > previousRate : false;
3434
const rateDifference = latestRate && previousRate ? ((latestRate - previousRate) / previousRate) * 100 : 0;
3535

@@ -48,7 +48,7 @@ export const TotalEarning: React.FC = () => {
4848
);
4949
}
5050

51-
const formattedLatestRate = latestRate !== undefined ? parseFloat(latestRate.toFixed(0)) : 0;
51+
const formattedLatestRate = latestRate !== undefined && !isNaN(latestRate) ? Math.round(latestRate) : 0;
5252
return (
5353
<NFTCard isSider>
5454
<BaseRow gutter={[14, 14]}>

0 commit comments

Comments
 (0)