From 1da7390e2f955e8abb80f3cba80e583532c7d0ae Mon Sep 17 00:00:00 2001
From: Yashvardhan Jagnani
Date: Sun, 8 Sep 2024 11:21:10 +0530
Subject: [PATCH] fix(fe): leaderboard
---
.../components/leaderboard/leaderboard.tsx | 214 ++++++++++--------
1 file changed, 114 insertions(+), 100 deletions(-)
diff --git a/packages/frontend/src/app/components/leaderboard/leaderboard.tsx b/packages/frontend/src/app/components/leaderboard/leaderboard.tsx
index 1e5527e..b0247fb 100644
--- a/packages/frontend/src/app/components/leaderboard/leaderboard.tsx
+++ b/packages/frontend/src/app/components/leaderboard/leaderboard.tsx
@@ -29,7 +29,9 @@ export const Leaderboard: React.FC = () => {
null,
);
const [loading, setLoading] = useState(false);
- const [leaderboard, setLeaderboard] = useState([]);
+ const [leaderboard, setLeaderboard] = useState(
+ null,
+ );
useEffect(() => {
(async () => {
@@ -90,112 +92,124 @@ export const Leaderboard: React.FC = () => {
- {selectedSeason && (
+ {selectedSeason && leaderboard && (
<>
{!selectedSeasonActive ? (
-
-
-
-
- {leaderboard[1].name}
-
-
-
- {truncate(
- leaderboard[1].wallet_address,
- ).toUpperCase()}
-
-
-
-
- {leaderboard[1].total_points?.toLocaleString()}
+ {leaderboard[1] ? (
+
+
+
+
+ {leaderboard[1].name}
+
+
+
+ {truncate(
+ leaderboard[1].wallet_address,
+ ).toUpperCase()}
+
+
+
+
+ {leaderboard[1].total_points?.toLocaleString()}
+
+
+
+ $
+ {calculatePercentage(
+ selectedSeason.reward_pool_usd,
+ rankTwoRewardPercentage,
+ ).toLocaleString()}
+
-
-
- $
- {calculatePercentage(
- selectedSeason.reward_pool_usd,
- rankTwoRewardPercentage,
- ).toLocaleString()}
-
-
-
-
-
-
-
- {leaderboard[0].name}
-
-
-
- {truncate(
- leaderboard[0].wallet_address,
- ).toUpperCase()}
-
-
-
-
- {leaderboard[0].total_points?.toLocaleString()}
+ ) : (
+
+ )}
+
+ {leaderboard[0] ? (
+
+
+
+
+ {leaderboard[0].name}
+
+
+
+ {truncate(
+ leaderboard[0].wallet_address,
+ ).toUpperCase()}
+
+
+
+
+ {leaderboard[0].total_points?.toLocaleString()}
+
+
+
+ $
+ {calculatePercentage(
+ selectedSeason.reward_pool_usd,
+ rankOwnRewardPercentage,
+ ).toLocaleString()}
+
-
-
- $
- {calculatePercentage(
- selectedSeason.reward_pool_usd,
- rankOwnRewardPercentage,
- ).toLocaleString()}
-
-
-
-
-
-
-
- {leaderboard[2].name}
-
-
-
- {truncate(
- leaderboard[2].wallet_address,
- ).toUpperCase()}
-
-
-
-
- {leaderboard[2].total_points?.toLocaleString()}
+ ) : (
+
+ )}
+
+ {leaderboard[2] ? (
+
+
+
+
+ {leaderboard[2].name}
+
+
+
+ {truncate(
+ leaderboard[2].wallet_address,
+ ).toUpperCase()}
+
+
+
+
+ {leaderboard[2].total_points?.toLocaleString()}
+
+
+
+ $
+ {calculatePercentage(
+ selectedSeason.reward_pool_usd,
+ rankThreeRewardPercentage,
+ ).toLocaleString()}
+
-
-
- $
- {calculatePercentage(
- selectedSeason.reward_pool_usd,
- rankThreeRewardPercentage,
- ).toLocaleString()}
-
-
+ ) : (
+
+ )}
) : (