From ba94e29ea7bf0f95dff68c9806f1f8281bba6dd7 Mon Sep 17 00:00:00 2001 From: aymericdelab Date: Wed, 11 Dec 2024 12:56:59 +0100 Subject: [PATCH] add back counter --- landing/src/hooks/use-season-start.tsx | 21 +++++++++++---------- landing/src/routes/index.lazy.tsx | 10 ++++++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/landing/src/hooks/use-season-start.tsx b/landing/src/hooks/use-season-start.tsx index 18d33ab07..b49fbc8b7 100644 --- a/landing/src/hooks/use-season-start.tsx +++ b/landing/src/hooks/use-season-start.tsx @@ -1,23 +1,24 @@ import { configManager } from "@/dojo/setup"; -import { useState } from "react"; +import { useEffect, useState } from "react"; export const useSeasonStart = () => { const seasonStart = BigInt(configManager.getSeasonConfig().startAt || 0); const nextBlockTimestamp = BigInt(Math.floor(Date.now() / 1000)); const [countdown, setCountdown] = useState(0n); - // useEffect(() => { - // if (nextBlockTimestamp === 0n || seasonStart === 0n) return; - // const initialCountdown = seasonStart - nextBlockTimestamp; - // setCountdown(initialCountdown); + useEffect(() => { + if (nextBlockTimestamp === 0n || seasonStart === 0n) return; - // const timer = setInterval(() => { - // setCountdown((prev) => prev - 1n); - // }, 1000); + const initialCountdown = seasonStart - nextBlockTimestamp; + setCountdown(initialCountdown); - // return () => clearInterval(timer); - // }, [nextBlockTimestamp, seasonStart]); + const timer = setInterval(() => { + setCountdown((prev) => prev - 1n); + }, 1000); + + return () => clearInterval(timer); + }, [nextBlockTimestamp, seasonStart]); return { seasonStart, countdown, nextBlockTimestamp }; }; diff --git a/landing/src/routes/index.lazy.tsx b/landing/src/routes/index.lazy.tsx index aa7ba5a7a..3fc9d35bc 100644 --- a/landing/src/routes/index.lazy.tsx +++ b/landing/src/routes/index.lazy.tsx @@ -1,7 +1,12 @@ import { AnimatedGrid } from "@/components/modules/animated-grid"; import { DataCard, DataCardProps } from "@/components/modules/data-card"; import { Leaderboard } from "@/components/modules/leaderboard"; -import { PRIZE_POOL_ACHIEVEMENTS, PRIZE_POOL_GUILDS, PRIZE_POOL_INDIVIDUAL_LEADERBOARD } from "@/constants"; +import { + PRIZE_POOL_ACHIEVEMENTS, + PRIZE_POOL_CONTENT_CREATORS, + PRIZE_POOL_GUILDS, + PRIZE_POOL_INDIVIDUAL_LEADERBOARD, +} from "@/constants"; import { useDonkeysBurned } from "@/hooks/use-donkeys-burned"; import { useLordsBridgeBalance } from "@/hooks/use-lords-bridged"; import { usePlayerCount } from "@/hooks/use-player-count"; @@ -81,7 +86,8 @@ function Index() { PRIZE_POOL_GUILDS + Number(formatEther(prizePoolPlayers)) + PRIZE_POOL_ACHIEVEMENTS + - PRIZE_POOL_INDIVIDUAL_LEADERBOARD, + PRIZE_POOL_INDIVIDUAL_LEADERBOARD + + PRIZE_POOL_CONTENT_CREATORS, 0, ), icon: ,