import { Box, Typography } from "@mui/material";

import { useQuizViewStore, updateAnswer } from "@root/quizView";

import type { QuizQuestionPage } from "../../../model/questionTypes/page";

type PageProps = {
  stepNumber: number;
  question: QuizQuestionPage;
};

export const Page = ({ stepNumber, question }: PageProps) => {
  const { answers } = useQuizViewStore();
  const { answer } = answers.find(({ step }) => step === stepNumber) ?? {};

  return (
    <Box>
      <Typography variant="h5">{question.title}</Typography>
      <Box
        sx={{
          display: "flex",
          flexDirection: "column",
          width: "100%",
          marginTop: "20px",
        }}
      >
        {question.content.picture && (
          <img
            src={question.content.picture}
            alt=""
            style={{
              display: "block",
              width: "100%",
              height: "100%",
              maxHeight: "80vh",
              objectFit: "contain",
            }}
          />
        )}
        {question.content.video && (
          <video
            src={question.content.video}
            controls
            style={{
              width: "100%",
              height: "100%",
              maxHeight: "80vh",
              objectFit: "contain",
            }}
          />
        )}
      </Box>
    </Box>
  );
};
