diff --git a/src/components/leaderboard/common/LeaderboardTable.tsx b/src/components/leaderboard/common/LeaderboardTable.tsx
index fdaa29802..946278278 100644
--- a/src/components/leaderboard/common/LeaderboardTable.tsx
+++ b/src/components/leaderboard/common/LeaderboardTable.tsx
@@ -30,7 +30,7 @@ import styles from './LeaderboardTable.module.sass'
export type LeaderboardTableProps = ComponentProps<'div'> & {
role: LeaderboardRole
currentUserRank?: {
- rank: number
+ rank?: number
reward: string
address: string
}
@@ -55,7 +55,7 @@ export default function LeaderboardTable({
addresses: string[]
slicedData: typeof data
}>(() => {
- if (!currentUserRank || currentUserRank.rank < TABLE_LIMIT) {
+ if (!currentUserRank || (currentUserRank?.rank ?? 0) < TABLE_LIMIT) {
return {
addresses: data.slice(0, TABLE_LIMIT).map(row => row.address),
slicedData: data.slice(0, TABLE_LIMIT),
@@ -161,7 +161,7 @@ function UserRow({
'!ColorNormal',
)}
>
- {data.rank + 1}
+ {data?.rank !== undefined && data.rank + 1}
{isLoading ? (
<>
diff --git a/src/components/utils/datahub/leaderboard.ts b/src/components/utils/datahub/leaderboard.ts
index 3f384c4d0..ed53c0618 100644
--- a/src/components/utils/datahub/leaderboard.ts
+++ b/src/components/utils/datahub/leaderboard.ts
@@ -116,11 +116,11 @@ export async function getUserStatistics({ address }: { address: string }): Promi
staker: {
reward: string
rankIndex: number
- }
+ } | null
creator: {
reward: string
rankIndex: number
- }
+ } | null
activeStakingAccountActivityMetricsForFixedPeriod: {
staker: {
likedCreators: number
@@ -146,11 +146,11 @@ export async function getUserStatistics({ address }: { address: string }): Promi
address,
creator: {
...res.data.activeStakingAccountActivityMetricsForFixedPeriod.creator,
- rank: res.data.creator.rankIndex,
+ rank: res.data.creator?.rankIndex,
},
staker: {
...res.data.activeStakingAccountActivityMetricsForFixedPeriod.staker,
- rank: res.data.staker.rankIndex,
+ rank: res.data.staker?.rankIndex,
},
}
}
diff --git a/src/rtk/features/leaderboard/leaderboardSlice.ts b/src/rtk/features/leaderboard/leaderboardSlice.ts
index 50289521f..30dfef11c 100644
--- a/src/rtk/features/leaderboard/leaderboardSlice.ts
+++ b/src/rtk/features/leaderboard/leaderboardSlice.ts
@@ -6,7 +6,7 @@ import { createSimpleFetchWrapper } from 'src/rtk/app/wrappers'
export type LeaderboardData = {
total: number
page: number
- data: { reward: string; rank: number; address: string }[]
+ data: { reward: string; rank?: number; address: string }[]
hasMore: boolean
role: LeaderboardRole
}
diff --git a/src/rtk/features/leaderboard/userStatisticsSlice.ts b/src/rtk/features/leaderboard/userStatisticsSlice.ts
index c26c933b5..99f9a2884 100644
--- a/src/rtk/features/leaderboard/userStatisticsSlice.ts
+++ b/src/rtk/features/leaderboard/userStatisticsSlice.ts
@@ -10,14 +10,14 @@ export type UserStatistics = {
likedPosts: number
earnedByPeriod: string
earnedTotal: string
- rank: number
+ rank: number | undefined
}
creator: {
likesCountByPeriod: number
stakersWhoLiked: number
earnedByPeriod: string
earnedTotal: string
- rank: number
+ rank: number | undefined
}
}