2023-11-30 17:39:57 +00:00
|
|
|
import { Box, Typography } from "@mui/material";
|
|
|
|
|
|
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
|
|
|
|
|
2023-12-01 13:48:25 +00:00
|
|
|
import { useQuizViewStore, updateAnswer } from "@root/quizView";
|
2023-11-30 17:39:57 +00:00
|
|
|
|
|
|
|
|
import type { QuizQuestionText } from "../../../model/questionTypes/text";
|
|
|
|
|
|
|
|
|
|
type TextProps = {
|
2023-12-01 13:48:25 +00:00
|
|
|
stepNumber: number;
|
2023-11-30 17:39:57 +00:00
|
|
|
question: QuizQuestionText;
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-01 13:48:25 +00:00
|
|
|
export const Text = ({ stepNumber, question }: TextProps) => {
|
|
|
|
|
const { answers } = useQuizViewStore();
|
|
|
|
|
const { answer } = answers.find(({ step }) => step === stepNumber) ?? {};
|
2023-11-30 17:39:57 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography variant="h5">{question.title}</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
width: "100%",
|
|
|
|
|
marginTop: "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-01 13:48:25 +00:00
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={question.content.placeholder}
|
|
|
|
|
value={answer || ""}
|
|
|
|
|
onChange={({ target }) => updateAnswer(stepNumber, target.value)}
|
|
|
|
|
/>
|
2023-11-30 17:39:57 +00:00
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|