* fix: Reward page render error #1006 * accept coderabbit's suggestion Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * address lint issues * use existing patterns --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
This commit is contained in:
parent
5fa7fd9a83
commit
2a08abd90c
@ -20,6 +20,7 @@ import { Col, Row } from 'react-bootstrap'
|
|||||||
import { proportions } from '@/lib/madness'
|
import { proportions } from '@/lib/madness'
|
||||||
import { useData } from '@/components/use-data'
|
import { useData } from '@/components/use-data'
|
||||||
import { GrowthPieChartSkeleton } from '@/components/charts-skeletons'
|
import { GrowthPieChartSkeleton } from '@/components/charts-skeletons'
|
||||||
|
import { useMemo } from 'react'
|
||||||
|
|
||||||
const GrowthPieChart = dynamic(() => import('@/components/charts').then(mod => mod.GrowthPieChart), {
|
const GrowthPieChart = dynamic(() => import('@/components/charts').then(mod => mod.GrowthPieChart), {
|
||||||
loading: () => <GrowthPieChartSkeleton />
|
loading: () => <GrowthPieChartSkeleton />
|
||||||
@ -95,15 +96,20 @@ export default function Rewards ({ ssrData }) {
|
|||||||
REWARDS,
|
REWARDS,
|
||||||
SSR ? {} : { pollInterval: 1000, nextFetchPolicy: 'cache-and-network' })
|
SSR ? {} : { pollInterval: 1000, nextFetchPolicy: 'cache-and-network' })
|
||||||
const { data } = useQuery(REWARDS_FULL)
|
const { data } = useQuery(REWARDS_FULL)
|
||||||
if (!data && !ssrData) return <PageLoading />
|
const dat = useData(data, ssrData)
|
||||||
|
|
||||||
|
let { rewards: [{ total, sources, time, leaderboard }] } = useMemo(() => {
|
||||||
|
return dat || { rewards: [{}] }
|
||||||
|
}, [dat])
|
||||||
|
|
||||||
let { rewards: [{ total, sources, time, leaderboard }] } = useData(data, ssrData)
|
|
||||||
if (rewardsData?.rewards?.length > 0) {
|
if (rewardsData?.rewards?.length > 0) {
|
||||||
total = rewardsData.rewards[0].total
|
total = rewardsData.rewards[0].total
|
||||||
sources = rewardsData.rewards[0].sources
|
sources = rewardsData.rewards[0].sources
|
||||||
time = rewardsData.rewards[0].time
|
time = rewardsData.rewards[0].time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dat) return <PageLoading />
|
||||||
|
|
||||||
function EstimatedReward ({ rank }) {
|
function EstimatedReward ({ rank }) {
|
||||||
const totalRest = total - 1000000
|
const totalRest = total - 1000000
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user