2023-12-29 00:58:19 +00:00
|
|
|
import { Box, Typography, useTheme } from "@mui/material";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
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 { QuizQuestionPage } from "../../../model/questionTypes/page";
|
2023-12-29 00:58:19 +00:00
|
|
|
import YoutubeEmbedIframe from "../tools/YoutubeEmbedIframe";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
|
|
type PageProps = {
|
|
|
|
currentQuestion: QuizQuestionPage;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Page = ({ currentQuestion }: PageProps) => {
|
2023-12-29 00:58:19 +00:00
|
|
|
const theme = useTheme();
|
2023-12-16 14:55:56 +00:00
|
|
|
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>
|
2023-12-29 00:58:19 +00:00
|
|
|
<Typography variant="h5" sx={{ paddingBottom: "25px", color: theme.palette.text.primary }}>{currentQuestion.title}</Typography>
|
|
|
|
<Typography color={theme.palette.text.primary}>{currentQuestion.content.text}</Typography>
|
2023-12-16 14:55:56 +00:00
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column",
|
|
|
|
width: "100%",
|
|
|
|
marginTop: "20px",
|
|
|
|
}}
|
|
|
|
>
|
2023-12-29 00:58:19 +00:00
|
|
|
{
|
|
|
|
//@ts-ignore
|
|
|
|
currentQuestion.content.useImage ? (
|
|
|
|
<Box sx={{ borderRadius: "12px", border: "1px solid #9A9AAF", overflow: "hidden" }}>
|
|
|
|
<img
|
|
|
|
src={currentQuestion.content.back}
|
|
|
|
alt=""
|
|
|
|
style={{
|
|
|
|
display: "block",
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
objectFit: "contain",
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
) : (
|
|
|
|
<YoutubeEmbedIframe
|
|
|
|
containerSX={{ width: "100%", height: "100%", maxHeight: "80vh", objectFit: "contain" }}
|
|
|
|
videoUrl={currentQuestion.content.video}
|
2023-12-16 14:55:56 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|