2024-04-23 14:45:49 +00:00
|
|
|
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
|
|
|
|
import type { QuizQuestionImages } from "@model/questionTypes/images";
|
2024-06-29 09:32:16 +00:00
|
|
|
import { Box, RadioGroup, Typography, useTheme } from "@mui/material";
|
2024-09-08 08:31:11 +00:00
|
|
|
import { createQuizViewStore, useQuizViewStore } from "@stores/quizView";
|
2024-06-29 09:32:16 +00:00
|
|
|
import { ImageVariant } from "./ImageVariant";
|
2024-04-23 14:45:49 +00:00
|
|
|
|
|
|
|
type ImagesProps = {
|
|
|
|
currentQuestion: QuizQuestionImages;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Images = ({ currentQuestion }: ImagesProps) => {
|
|
|
|
const answers = useQuizViewStore((state) => state.answers);
|
|
|
|
const theme = useTheme();
|
2024-05-31 16:41:18 +00:00
|
|
|
const answer = answers.find(({ questionId }) => questionId === currentQuestion.id)?.answer;
|
2024-04-23 14:45:49 +00:00
|
|
|
const isTablet = useRootContainerSize() < 1000;
|
|
|
|
const isMobile = useRootContainerSize() < 500;
|
2024-09-08 08:31:11 +00:00
|
|
|
const a = createQuizViewStore().getState();
|
|
|
|
console.log(currentQuestion);
|
|
|
|
console.log("store");
|
|
|
|
console.log(a);
|
2024-04-23 14:45:49 +00:00
|
|
|
return (
|
|
|
|
<Box>
|
2024-06-29 09:32:16 +00:00
|
|
|
<Typography
|
|
|
|
variant="h5"
|
|
|
|
color={theme.palette.text.primary}
|
|
|
|
sx={{ wordBreak: "break-word" }}
|
|
|
|
>
|
2024-04-23 14:45:49 +00:00
|
|
|
{currentQuestion.title}
|
|
|
|
</Typography>
|
|
|
|
<RadioGroup
|
|
|
|
name={currentQuestion.id}
|
2024-05-31 16:41:18 +00:00
|
|
|
value={currentQuestion.content.variants.findIndex(({ id }) => answer === id)}
|
2024-04-23 14:45:49 +00:00
|
|
|
sx={{
|
|
|
|
display: "flex",
|
|
|
|
flexWrap: "wrap",
|
|
|
|
flexDirection: "row",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
marginTop: "20px",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
display: "grid",
|
|
|
|
gap: "15px",
|
2024-05-31 16:41:18 +00:00
|
|
|
gridTemplateColumns: isTablet ? (isMobile ? "repeat(1, 1fr)" : "repeat(2, 1fr)") : "repeat(3, 1fr)",
|
2024-04-23 14:45:49 +00:00
|
|
|
width: "100%",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{currentQuestion.content.variants.map((variant, index) => (
|
|
|
|
<ImageVariant
|
|
|
|
key={variant.id}
|
2024-06-29 09:32:16 +00:00
|
|
|
questionId={currentQuestion.id}
|
2024-04-23 14:45:49 +00:00
|
|
|
variant={variant}
|
|
|
|
index={index}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Box>
|
|
|
|
</RadioGroup>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|