|
|
@@ -14,23 +14,26 @@ interface OwnProp { |
|
|
|
let timeout: NodeJS.Timeout; |
|
|
|
|
|
|
|
const Question: React.FC<OwnProp> = (props) => { |
|
|
|
|
|
|
|
const [seconds, setSeconds] = useState<number>(props.timeLimit); |
|
|
|
const [duration, setDuration] = useState<number>(props.timeLimit); |
|
|
|
const displaySeconds = seconds % 60; |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setSeconds(props.timeLimit); |
|
|
|
setDuration(props.timeLimit); |
|
|
|
}, [props.questionNumber]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setTimeout(() => { |
|
|
|
if (seconds <= 0) { |
|
|
|
props.updateQuestionNumber(); |
|
|
|
console.log(props.timeLimit); |
|
|
|
setSeconds(5) |
|
|
|
} else { |
|
|
|
if (seconds > 0) { |
|
|
|
setSeconds(seconds - 1); |
|
|
|
} else { |
|
|
|
props.updateQuestionNumber(); |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, 1000); |
|
|
|
}, [seconds]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const renderTime = () => { |
|
|
|
return ( |
|
|
|
<div className={styles.time}> |
|
|
@@ -56,13 +59,11 @@ const Question: React.FC<OwnProp> = (props) => { |
|
|
|
|
|
|
|
<CountdownCircleTimer |
|
|
|
isPlaying |
|
|
|
duration={props.timeLimit} |
|
|
|
duration={duration} |
|
|
|
colors={'#6BD534'} |
|
|
|
size={60} |
|
|
|
onComplete={() => { |
|
|
|
// setSeconds(COUNTDOWN_AMOUNT_TOTAL); |
|
|
|
// props.updateQuestionNumber(); |
|
|
|
return { shouldRepeat: true } |
|
|
|
return { shouldRepeat: true, delay: 1.5 } |
|
|
|
}} |
|
|
|
strokeWidth={5} > |
|
|
|
|
|
|
|