"use client"; import { useState, useEffect } from "react"; import { motion } from "framer-motion"; interface ChallengeButtonProps { coins: number; costToChallenge: number; onChallenge: () => void; disabled?: boolean; } export function ChallengeButton({ coins, costToChallenge, onChallenge, disabled, }: ChallengeButtonProps) { const [secondsLeft, setSecondsLeft] = useState(30); useEffect(() => { if (secondsLeft <= 0) return; const timer = setTimeout(() => setSecondsLeft((s) => s - 1), 1000); return () => clearTimeout(timer); }, [secondsLeft]); const visible = secondsLeft > 0; if (!visible) return null; const canAfford = coins >= costToChallenge; return ( Challenge Verdict ({costToChallenge} coins)
{secondsLeft}s
); }