2024-02-19 14:20:21 +00:00
|
|
|
import { Box, Link, useTheme } from "@mui/material";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
import { Footer } from "./Footer";
|
2023-12-16 14:55:56 +00:00
|
|
|
import { Date } from "./questions/Date";
|
2024-01-30 16:49:33 +00:00
|
|
|
import { Emoji } from "./questions/Emoji";
|
2023-12-16 14:55:56 +00:00
|
|
|
import { File } from "./questions/File";
|
2024-01-30 16:49:33 +00:00
|
|
|
import { Images } from "./questions/Images";
|
|
|
|
import { Number } from "./questions/Number";
|
2023-12-16 14:55:56 +00:00
|
|
|
import { Page } from "./questions/Page";
|
|
|
|
import { Rating } from "./questions/Rating";
|
2024-01-30 16:49:33 +00:00
|
|
|
import { Select } from "./questions/Select";
|
|
|
|
import { Text } from "./questions/Text";
|
|
|
|
import { Variant } from "./questions/Variant";
|
|
|
|
import { Varimg } from "./questions/Varimg";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
import type { RealTypedQuizQuestion } from "../../model/questionTypes/shared";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
2024-02-19 14:20:21 +00:00
|
|
|
import { useQuizData } from "@contexts/QuizDataContext";
|
2024-01-30 16:49:33 +00:00
|
|
|
import { NameplateLogoFQ } from "@icons/NameplateLogoFQ";
|
|
|
|
import { NameplateLogoFQDark } from "@icons/NameplateLogoFQDark";
|
|
|
|
import { notReachable } from "@utils/notReachable";
|
|
|
|
import { quizThemes } from "@utils/themes/Publication/themePublication";
|
2024-03-01 14:08:09 +00:00
|
|
|
|
2024-04-03 12:42:12 +00:00
|
|
|
import { DESIGN_LIST } from "@/utils/designList";
|
2024-04-11 14:11:43 +00:00
|
|
|
import type { ReactNode } from "react";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
type Props = {
|
2024-04-03 12:42:12 +00:00
|
|
|
currentQuestion: RealTypedQuizQuestion;
|
|
|
|
currentQuestionStepNumber: number | null;
|
|
|
|
nextButton: ReactNode;
|
|
|
|
prevButton: ReactNode;
|
2024-04-11 14:11:43 +00:00
|
|
|
questionSelect: ReactNode;
|
2024-03-01 14:08:09 +00:00
|
|
|
};
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
export const Question = ({
|
2024-04-03 12:42:12 +00:00
|
|
|
currentQuestion,
|
|
|
|
currentQuestionStepNumber,
|
|
|
|
nextButton,
|
|
|
|
prevButton,
|
2024-04-11 14:11:43 +00:00
|
|
|
questionSelect,
|
2024-02-08 13:42:31 +00:00
|
|
|
}: Props) => {
|
2024-04-03 12:42:12 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
const { settings, show_badge } = useQuizData();
|
2024-03-01 14:08:09 +00:00
|
|
|
|
2024-04-03 12:42:12 +00:00
|
|
|
return (
|
2024-03-01 14:08:09 +00:00
|
|
|
<Box
|
2024-03-26 00:06:54 +00:00
|
|
|
sx={{
|
2024-04-03 12:42:12 +00:00
|
|
|
height: "100%",
|
|
|
|
backgroundPosition: "center",
|
|
|
|
backgroundSize: "cover",
|
|
|
|
backgroundImage: settings.cfg.design
|
|
|
|
? `url(${DESIGN_LIST[settings.cfg.theme]})`
|
|
|
|
: null,
|
2024-03-26 00:06:54 +00:00
|
|
|
}}
|
2024-03-01 14:08:09 +00:00
|
|
|
>
|
2024-04-03 12:42:12 +00:00
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
height: "100%",
|
2024-04-06 14:02:16 +00:00
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column",
|
2024-04-03 12:42:12 +00:00
|
|
|
background: settings.cfg.design
|
|
|
|
? quizThemes[settings.cfg.theme].isLight
|
|
|
|
? "transparent"
|
|
|
|
: "linear-gradient(90deg,#272626, transparent)"
|
|
|
|
: theme.palette.background.default,
|
|
|
|
overflow: "hidden"
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
overflow: "auto",
|
2024-04-06 14:02:16 +00:00
|
|
|
width: "100%",
|
|
|
|
flexGrow: 1,
|
2024-04-17 00:02:08 +00:00
|
|
|
scrollbarWidth: "none",
|
|
|
|
"&::-webkit-scrollbar": {
|
|
|
|
width: 0,
|
|
|
|
},
|
2024-04-03 12:42:12 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
width: "100%",
|
2024-04-08 14:48:24 +00:00
|
|
|
minHeight: "100%",
|
2024-04-03 12:42:12 +00:00
|
|
|
maxWidth: "1440px",
|
|
|
|
padding: "40px 25px 20px",
|
|
|
|
margin: "0 auto",
|
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<QuestionByType
|
|
|
|
key={currentQuestion.id}
|
|
|
|
question={currentQuestion}
|
|
|
|
stepNumber={currentQuestionStepNumber}
|
|
|
|
/>
|
|
|
|
{show_badge && (
|
2024-04-06 14:02:16 +00:00
|
|
|
<Link
|
|
|
|
target="_blank"
|
|
|
|
href="https://quiz.pena.digital"
|
|
|
|
sx={{
|
2024-04-08 14:48:24 +00:00
|
|
|
mt: "20px",
|
|
|
|
alignSelf: "end",
|
2024-04-06 14:02:16 +00:00
|
|
|
}}
|
|
|
|
>
|
2024-04-03 12:42:12 +00:00
|
|
|
{quizThemes[settings.cfg.theme].isLight ? (
|
|
|
|
<NameplateLogoFQ
|
2024-04-06 14:02:16 +00:00
|
|
|
style={{
|
|
|
|
fontSize: "34px",
|
|
|
|
width: "200px",
|
|
|
|
height: "auto",
|
|
|
|
}}
|
2024-04-03 12:42:12 +00:00
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<NameplateLogoFQDark
|
2024-04-06 14:02:16 +00:00
|
|
|
style={{
|
|
|
|
fontSize: "34px",
|
|
|
|
width: "200px",
|
|
|
|
height: "auto",
|
|
|
|
}}
|
2024-04-03 12:42:12 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Link>
|
|
|
|
)}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
2024-04-11 14:11:43 +00:00
|
|
|
{questionSelect}
|
2024-04-03 12:42:12 +00:00
|
|
|
<Footer
|
|
|
|
stepNumber={currentQuestionStepNumber}
|
|
|
|
prevButton={prevButton}
|
|
|
|
nextButton={nextButton}
|
|
|
|
/>
|
|
|
|
</Box>
|
2024-03-01 14:08:09 +00:00
|
|
|
</Box>
|
2024-04-03 12:42:12 +00:00
|
|
|
);
|
2023-12-16 14:55:56 +00:00
|
|
|
};
|
2024-01-30 16:49:33 +00:00
|
|
|
|
2024-02-29 14:07:09 +00:00
|
|
|
function QuestionByType({
|
2024-04-03 12:42:12 +00:00
|
|
|
question,
|
|
|
|
stepNumber,
|
2024-02-29 14:07:09 +00:00
|
|
|
}: {
|
2024-04-03 12:42:12 +00:00
|
|
|
question: RealTypedQuizQuestion;
|
|
|
|
stepNumber: number | null;
|
2024-01-30 16:49:33 +00:00
|
|
|
}) {
|
2024-04-03 12:42:12 +00:00
|
|
|
switch (question.type) {
|
|
|
|
case "variant":
|
|
|
|
return <Variant currentQuestion={question} />;
|
|
|
|
case "images":
|
|
|
|
return <Images currentQuestion={question} />;
|
|
|
|
case "varimg":
|
|
|
|
return <Varimg currentQuestion={question} />;
|
|
|
|
case "emoji":
|
|
|
|
return <Emoji currentQuestion={question} />;
|
|
|
|
case "text":
|
|
|
|
return <Text currentQuestion={question} stepNumber={stepNumber} />;
|
|
|
|
case "select":
|
|
|
|
return <Select currentQuestion={question} />;
|
|
|
|
case "date":
|
|
|
|
return <Date currentQuestion={question} />;
|
|
|
|
case "number":
|
|
|
|
return <Number currentQuestion={question} />;
|
|
|
|
case "file":
|
|
|
|
return <File currentQuestion={question} />;
|
|
|
|
case "page":
|
|
|
|
return <Page currentQuestion={question} />;
|
|
|
|
case "rating":
|
|
|
|
return <Rating currentQuestion={question} />;
|
|
|
|
default:
|
|
|
|
notReachable(question);
|
|
|
|
}
|
2024-01-30 16:49:33 +00:00
|
|
|
}
|