2024-01-10 18:02:37 +00:00
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Typography,
|
|
|
|
|
Button,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
|
|
|
|
} from "@mui/material";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-01-19 11:46:17 +00:00
|
|
|
|
import { useQuestionsStore } from "@stores/quizData/store";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-01-10 18:02:37 +00:00
|
|
|
|
import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe";
|
2023-12-21 19:22:06 +00:00
|
|
|
|
import { NameplateLogo } from "@icons/NameplateLogo";
|
2023-12-29 00:58:19 +00:00
|
|
|
|
import { modes } from "../../utils/themes/Publication/themePublication";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-01-10 18:02:37 +00:00
|
|
|
|
import type { QuizQuestionResult } from "../../model/questionTypes/result";
|
|
|
|
|
|
2023-12-16 14:55:56 +00:00
|
|
|
|
type ResultFormProps = {
|
2023-12-17 13:22:21 +00:00
|
|
|
|
currentQuestion: any;
|
2023-12-16 14:55:56 +00:00
|
|
|
|
showContactForm: boolean;
|
|
|
|
|
setShowContactForm: (show: boolean) => void;
|
|
|
|
|
setShowResultForm: (show: boolean) => void;
|
|
|
|
|
};
|
|
|
|
|
export const ResultForm = ({
|
|
|
|
|
currentQuestion,
|
|
|
|
|
showContactForm,
|
|
|
|
|
setShowContactForm,
|
|
|
|
|
setShowResultForm,
|
|
|
|
|
}: ResultFormProps) => {
|
2024-01-05 17:00:30 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(650));
|
2024-01-10 18:02:37 +00:00
|
|
|
|
const { settings, items } = useQuestionsStore();
|
2023-12-29 00:58:19 +00:00
|
|
|
|
const mode = modes;
|
|
|
|
|
|
2024-01-10 18:02:37 +00:00
|
|
|
|
const searchResult = (): QuizQuestionResult => {
|
2024-01-05 17:00:30 +00:00
|
|
|
|
if (Boolean(settings?.cfg.haveRoot)) {
|
|
|
|
|
//ищём для ветвления
|
|
|
|
|
return (items.find(
|
|
|
|
|
(question) =>
|
|
|
|
|
question.type === "result" &&
|
2024-01-10 18:02:37 +00:00
|
|
|
|
question.content.rule.parentId === currentQuestion.content.id
|
2024-01-05 17:00:30 +00:00
|
|
|
|
) ||
|
2024-01-10 18:02:37 +00:00
|
|
|
|
items.find(
|
2024-01-05 17:00:30 +00:00
|
|
|
|
(question) =>
|
|
|
|
|
question.type === "result" &&
|
2024-01-10 18:02:37 +00:00
|
|
|
|
question.content.rule.parentId === "line"
|
|
|
|
|
)) as QuizQuestionResult;
|
2024-01-05 17:00:30 +00:00
|
|
|
|
} else {
|
|
|
|
|
return items.find(
|
|
|
|
|
(question) =>
|
|
|
|
|
question.type === "result" &&
|
2024-01-10 18:02:37 +00:00
|
|
|
|
question.content.rule.parentId === "line"
|
|
|
|
|
) as QuizQuestionResult;
|
2024-01-05 17:00:30 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const resultQuestion = searchResult();
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
|
|
|
|
const followNextForm = () => {
|
|
|
|
|
setShowResultForm(false);
|
|
|
|
|
setShowContactForm(true);
|
|
|
|
|
};
|
2024-01-10 18:02:37 +00:00
|
|
|
|
console.log(resultQuestion);
|
2023-12-17 13:22:21 +00:00
|
|
|
|
if (resultQuestion === null || resultQuestion === undefined) {
|
2024-01-10 18:02:37 +00:00
|
|
|
|
followNextForm();
|
|
|
|
|
return <></>;
|
2023-12-17 13:22:21 +00:00
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between",
|
2024-01-10 13:39:07 +00:00
|
|
|
|
height: "100vh",
|
2023-12-17 13:22:21 +00:00
|
|
|
|
width: "100vw",
|
2023-12-29 00:58:19 +00:00
|
|
|
|
pt: "28px",
|
2024-01-10 18:02:37 +00:00
|
|
|
|
overflow: "auto",
|
2023-12-17 13:22:21 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "start",
|
2024-01-05 17:00:30 +00:00
|
|
|
|
width: isMobile ? "100%" : "490px",
|
|
|
|
|
padding: isMobile ? "0 16px" : undefined,
|
2023-12-17 13:22:21 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{
|
2023-12-21 19:22:06 +00:00
|
|
|
|
//@ts-ignore
|
2024-01-10 18:02:37 +00:00
|
|
|
|
!resultQuestion?.content.useImage &&
|
|
|
|
|
resultQuestion.content.video && (
|
|
|
|
|
<YoutubeEmbedIframe
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
videoUrl={resultQuestion.content.video}
|
|
|
|
|
containerSX={{
|
|
|
|
|
width: isMobile ? "100%" : "490px",
|
|
|
|
|
height: isMobile ? "100%" : "280px",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
2023-12-17 13:22:21 +00:00
|
|
|
|
{
|
2023-12-21 19:22:06 +00:00
|
|
|
|
//@ts-ignore
|
2023-12-29 00:58:19 +00:00
|
|
|
|
resultQuestion?.content.useImage && resultQuestion.content.back && (
|
|
|
|
|
<Box
|
|
|
|
|
component="img"
|
|
|
|
|
src={resultQuestion.content.back}
|
|
|
|
|
sx={{
|
2024-01-05 17:00:30 +00:00
|
|
|
|
width: isMobile ? "100%" : "490px",
|
|
|
|
|
height: isMobile ? "100%" : "280px",
|
2023-12-29 00:58:19 +00:00
|
|
|
|
}}
|
|
|
|
|
></Box>
|
2024-01-10 18:02:37 +00:00
|
|
|
|
)
|
|
|
|
|
}
|
2023-12-29 00:58:19 +00:00
|
|
|
|
{resultQuestion.description !== "" &&
|
|
|
|
|
resultQuestion.description !== " " && (
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "23px",
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
m: "20px 0",
|
2024-01-05 17:00:30 +00:00
|
|
|
|
color: theme.palette.text.primary,
|
2023-12-29 00:58:19 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.description}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
2023-12-29 00:58:19 +00:00
|
|
|
|
m: "20px 0",
|
2024-01-05 17:00:30 +00:00
|
|
|
|
color: theme.palette.text.primary,
|
2023-12-17 13:22:21 +00:00
|
|
|
|
}}
|
2023-12-29 00:58:19 +00:00
|
|
|
|
>
|
2024-01-05 17:00:30 +00:00
|
|
|
|
{resultQuestion.title}
|
2023-12-17 13:22:21 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
|
2023-12-25 08:25:55 +00:00
|
|
|
|
{
|
|
|
|
|
//@ts-ignore
|
2023-12-29 00:58:19 +00:00
|
|
|
|
resultQuestion.content.text !== "" &&
|
2024-01-10 18:02:37 +00:00
|
|
|
|
//@ts-ignore
|
|
|
|
|
resultQuestion.content.text !== " " && (
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
resultQuestion.content.text
|
|
|
|
|
}
|
|
|
|
|
</Typography>
|
|
|
|
|
)
|
|
|
|
|
}
|
2023-12-17 13:22:21 +00:00
|
|
|
|
</Box>
|
|
|
|
|
|
2023-12-21 19:22:06 +00:00
|
|
|
|
<Box width="100%">
|
2023-12-17 13:22:21 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
2023-12-21 19:22:06 +00:00
|
|
|
|
width: "100%",
|
|
|
|
|
justifyContent: "end",
|
2023-12-29 00:58:19 +00:00
|
|
|
|
px: "20px",
|
2023-12-17 13:22:21 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
<Box
|
2023-12-17 13:22:21 +00:00
|
|
|
|
sx={{
|
2023-12-21 19:22:06 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
2023-12-29 00:58:19 +00:00
|
|
|
|
mt: "15px",
|
2024-01-05 17:00:30 +00:00
|
|
|
|
gap: "10px",
|
2023-12-17 13:22:21 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-01-10 18:02:37 +00:00
|
|
|
|
<NameplateLogo
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: "34px",
|
|
|
|
|
color: mode[settings.cfg.theme] ? "#000000" : "#F5F7FF",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-12-29 00:58:19 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "20px",
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
color: mode[settings.cfg.theme] ? "#4D4D4D" : "#F5F7FF",
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Сделано на PenaQuiz
|
|
|
|
|
</Typography>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
</Box>
|
2023-12-17 13:22:21 +00:00
|
|
|
|
</Box>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
|
2024-01-10 18:02:37 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
boxShadow: "0 0 15px 0 rgba(0,0,0,.08)",
|
|
|
|
|
width: "100%",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
p: "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{settings?.cfg.resultInfo.showResultForm === "before" && (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={followNextForm}
|
|
|
|
|
variant="contained"
|
2023-12-21 19:22:06 +00:00
|
|
|
|
sx={{
|
2024-01-10 18:02:37 +00:00
|
|
|
|
p: "10px 20px",
|
|
|
|
|
width: "210px",
|
|
|
|
|
height: "50px",
|
2023-12-21 19:22:06 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-01-10 18:02:37 +00:00
|
|
|
|
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
{settings?.cfg.resultInfo.showResultForm === "after" &&
|
|
|
|
|
resultQuestion.content.redirect && (
|
2023-12-29 00:58:19 +00:00
|
|
|
|
<Button
|
2024-01-10 18:02:37 +00:00
|
|
|
|
href={resultQuestion.content.redirect}
|
2023-12-29 00:58:19 +00:00
|
|
|
|
variant="contained"
|
2024-01-10 18:02:37 +00:00
|
|
|
|
sx={{ p: "10px 20px", width: "210px", height: "50px" }}
|
2023-12-29 00:58:19 +00:00
|
|
|
|
>
|
2024-01-10 18:02:37 +00:00
|
|
|
|
{resultQuestion.content.hint.text || "Перейти на сайт"}
|
2023-12-29 00:58:19 +00:00
|
|
|
|
</Button>
|
2024-01-10 18:02:37 +00:00
|
|
|
|
)}
|
|
|
|
|
</Box>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
</Box>
|
2023-12-17 13:22:21 +00:00
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-01-10 18:02:37 +00:00
|
|
|
|
};
|