2023-12-16 14:55:56 +00:00
|
|
|
import { Box, Typography } from "@mui/material";
|
|
|
|
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
|
|
|
|
2023-12-17 13:22:21 +00:00
|
|
|
import { useQuizViewStore, updateAnswer } from "@root/quizView/store";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
|
|
import type { QuizQuestionText } from "../../../model/questionTypes/text";
|
|
|
|
|
|
|
|
type TextProps = {
|
|
|
|
currentQuestion: QuizQuestionText;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Text = ({ currentQuestion }: TextProps) => {
|
|
|
|
const { answers } = useQuizViewStore();
|
2023-12-17 13:22:21 +00:00
|
|
|
const { answer } = answers.find(({ questionId }) => questionId === currentQuestion.id) ?? {};
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Box>
|
|
|
|
<Typography variant="h5">{currentQuestion.title}</Typography>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column",
|
|
|
|
width: "100%",
|
|
|
|
marginTop: "20px",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<CustomTextField
|
|
|
|
placeholder={currentQuestion.content.placeholder}
|
2023-12-17 13:22:21 +00:00
|
|
|
//@ts-ignore
|
2023-12-16 14:55:56 +00:00
|
|
|
value={answer || ""}
|
2023-12-17 13:22:21 +00:00
|
|
|
onChange={({ target }) => updateAnswer(currentQuestion.id, target.value)}
|
2023-12-16 14:55:56 +00:00
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|