/** * This file is part of the SplendidBear Websites' projects. * * Copyright (c) 2026 @ www.splendidbear.org * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import { Fragment, useEffect, useState } from 'react'; import { func, number } from 'prop-types'; const ChallengeCountdown = ({ onAccept, onDecline, seconds = 30 }) => { const [countdown, setCountdown] = useState(seconds); useEffect(() => { const interval = setInterval(() => { setCountdown(prev => { if (1 >= prev) { clearInterval(interval); onDecline(); return 0; } return prev - 1; }); }, 1000); return () => clearInterval(interval); }, [onDecline]); return (

You have {countdown} second{1 === countdown ? '' : 's'} to answer to the challenge!

Accept Decline
); }; export default ChallengeCountdown; ChallengeCountdown.propTypes = { onAccept: func.isRequired, onDecline: func.isRequired, seconds: number, };