2023-12-16 14:55:56 +00:00
|
|
|
|
import { Box, Typography, Button } from "@mui/material";
|
|
|
|
|
|
2023-12-17 13:22:21 +00:00
|
|
|
|
import { useQuestionsStore } from "@root/quizData/store"
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2023-12-17 13:22:21 +00:00
|
|
|
|
import type { QuizQuestionResult } from "@model/questionTypes/result";
|
|
|
|
|
import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe"
|
2023-12-21 19:22:06 +00:00
|
|
|
|
import { NameplateLogo } from "@icons/NameplateLogo";
|
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,
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
2023-12-16 14:55:56 +00:00
|
|
|
|
}: ResultFormProps) => {
|
2023-12-17 13:22:21 +00:00
|
|
|
|
const { settings, items } = useQuestionsStore()
|
|
|
|
|
|
|
|
|
|
const resultQuestion = items.find(
|
2023-12-16 14:55:56 +00:00
|
|
|
|
(question) =>
|
|
|
|
|
question.type === "result" &&
|
2023-12-17 13:22:21 +00:00
|
|
|
|
(question.content.rule.parentId === "line" || currentQuestion.id)
|
2023-12-16 14:55:56 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const followNextForm = () => {
|
|
|
|
|
setShowResultForm(false);
|
|
|
|
|
setShowContactForm(true);
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-17 13:22:21 +00:00
|
|
|
|
if (resultQuestion === null || resultQuestion === undefined) {
|
|
|
|
|
|
|
|
|
|
followNextForm()
|
|
|
|
|
return <></>
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
height: "100vh",
|
|
|
|
|
width: "100vw",
|
|
|
|
|
pt: "28px"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "start",
|
|
|
|
|
width: "490px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{
|
2023-12-21 19:22:06 +00:00
|
|
|
|
//@ts-ignore
|
2023-12-17 13:22:21 +00:00
|
|
|
|
!resultQuestion?.content.useImage &&
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
resultQuestion.content.video &&
|
|
|
|
|
<YoutubeEmbedIframe
|
2023-12-21 19:22:06 +00:00
|
|
|
|
//@ts-ignore
|
2023-12-17 13:22:21 +00:00
|
|
|
|
videoUrl={resultQuestion.content.video}
|
|
|
|
|
containerSX={{
|
|
|
|
|
width: "490px",
|
|
|
|
|
height: "280px"
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
{
|
2023-12-21 19:22:06 +00:00
|
|
|
|
//@ts-ignore
|
2023-12-17 13:22:21 +00:00
|
|
|
|
resultQuestion?.content.useImage &&
|
|
|
|
|
resultQuestion.content.back &&
|
|
|
|
|
<Box
|
|
|
|
|
component='img'
|
|
|
|
|
src={resultQuestion.content.back}
|
|
|
|
|
sx={{
|
|
|
|
|
width: "490px",
|
|
|
|
|
height: "280px"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
{resultQuestion.description !== "" && resultQuestion.description !== " " && <Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "23px",
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
m: "20px 0"
|
|
|
|
|
}}
|
|
|
|
|
>{resultQuestion.description}</Typography>}
|
|
|
|
|
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
m: "20px 0"
|
|
|
|
|
}}
|
|
|
|
|
>{resultQuestion.title || "Форма результатов"}
|
|
|
|
|
</Typography>
|
|
|
|
|
|
2023-12-24 11:52:09 +00:00
|
|
|
|
{resultQuestion.content.text !== "" && resultQuestion.content.text !== " " && <Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
m: "20px 0"
|
|
|
|
|
}}
|
|
|
|
|
>{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",
|
|
|
|
|
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",
|
|
|
|
|
mt: "15px"
|
2023-12-17 13:22:21 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
<NameplateLogo style={{ fontSize: "34px" }} />
|
|
|
|
|
<Typography sx={{ fontSize: "20px", color: "#4D4D4D", whiteSpace: "nowrap" }}>Сделано на PenaQuiz</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
|
2023-12-17 13:22:21 +00:00
|
|
|
|
</Box>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
settings?.cfg.resultInfo.when === "before" &&
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
height: "100px",
|
|
|
|
|
boxShadow: "0 0 15px 0 rgba(0,0,0,.08)",
|
|
|
|
|
width: "100%",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={followNextForm}
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
p: "10px 20px",
|
|
|
|
|
width: "210px",
|
|
|
|
|
height: "50px"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
</Box>
|
2023-12-17 13:22:21 +00:00
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|