diff --git a/components/Game.tsx b/components/Game.tsx index 51389e4..cdfe87c 100644 --- a/components/Game.tsx +++ b/components/Game.tsx @@ -31,6 +31,25 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max const [shareText, setShareText] = useState('🔗 Share'); const [lastAction, setLastAction] = useState<'GUESS' | 'SKIP' | null>(null); const [isProcessingGuess, setIsProcessingGuess] = useState(false); + const [timeUntilNext, setTimeUntilNext] = useState(''); + + useEffect(() => { + const updateCountdown = () => { + const now = new Date(); + const tomorrow = new Date(now); + tomorrow.setHours(24, 0, 0, 0); + const diff = tomorrow.getTime() - now.getTime(); + + const hours = Math.floor(diff / (1000 * 60 * 60)); + const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); + + setTimeUntilNext(`${hours}h ${minutes}m`); + }; + + updateCountdown(); + const interval = setInterval(updateCountdown, 1000); // Update every second to be accurate + return () => clearInterval(interval); + }, []); useEffect(() => { if (gameState && dailyPuzzle) { @@ -160,6 +179,9 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max

Hördle #{dailyPuzzle.id}{genre ? ` / ${genre}` : ''}

+
+ Next puzzle in: {timeUntilNext} +