fix: 퀴즈 제한시간 수정

This commit is contained in:
jhynsoo 2024-08-07 12:40:31 +09:00
parent fdd6e9dee4
commit 7f3b1b9900
3 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@ import { useState } from 'react';
import { STATIC_URL } from '../../constants';
import styles from './Quiz.module.css';
export default function Quiz({ question, step, image, choices = [], setAnswers }) {
export default function Quiz({ question, image, choices = [], setAnswers }) {
const [answer, setAnswer] = useState(null);
const isChoice = choices.length > 0;
@ -37,9 +37,9 @@ export default function Quiz({ question, step, image, choices = [], setAnswers }
type="text"
autoFocus
placeholder="답 입력"
onChange={(e) =>
setAnswers((prev) => prev.map((value, index) => (index === step ? e.target.value : value)))
}
onChange={(e) => {
setAnswers(e.target.value);
}}
className={styles.input}
/>
)}

View File

@ -17,7 +17,10 @@ export default function QuizSet({ quizSetId, finish }) {
const interval = useRef(null);
const submit = useCallback(
(data) => {
instance.post(`${API_URL}/report/submit/${roomId}/quizset/${quizSetId}`, data).catch(() => {});
const requestData = {
answer: data,
};
instance.post(`${API_URL}/report/submit/${roomId}/quizset/${quizSetId}`, requestData).catch(() => {});
},
[quizSetId, roomId]
);
@ -25,7 +28,6 @@ export default function QuizSet({ quizSetId, finish }) {
...quizList.map((quiz, index) => (
<Quiz
key={index}
step={index}
answers={answers.current}
setAnswers={(value) => {
answers.current = answers.current.map((v, i) => (i === index ? value : v));
@ -60,7 +62,7 @@ export default function QuizSet({ quizSetId, finish }) {
return prev + 1;
});
}, 5000);
}, 10 * 1000);
return () => {
clearInterval(interval.current);
@ -78,7 +80,7 @@ export default function QuizSet({ quizSetId, finish }) {
<>
{step === null ? (
<div className={styles.message}>
<span>퀴즈를 시작합니다</span>
<span>10 퀴즈를 시작합니다.</span>
<LoadingIndicator />
</div>
) : (

View File

@ -40,5 +40,5 @@
overflow: hidden;
margin-top: 16px;
transform-origin: left center;
animation: progress 5s linear infinite;
animation: progress 10s linear infinite;
}