2023-12-15 12:12:36 +00:00
|
|
|
|
import { Box, Typography, Button } from "@mui/material";
|
2023-12-16 12:33:06 +00:00
|
|
|
|
import { getQuestionByContentId } from "@root/questions/actions";
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
|
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
2023-12-16 09:36:35 +00:00
|
|
|
|
import { useQuestionsStore } from "@root/questions/store";
|
|
|
|
|
|
|
|
|
|
|
|
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
2023-12-28 14:10:21 +00:00
|
|
|
|
import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx";
|
2023-12-21 11:47:34 +00:00
|
|
|
|
import { NameplateLogo } from "@icons/NameplateLogo";
|
2023-12-28 14:10:21 +00:00
|
|
|
|
import { modes } from "../../utils/themes/Publication/themePublication";
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
|
|
|
|
|
type ResultFormProps = {
|
2023-12-16 09:36:35 +00:00
|
|
|
|
currentQuestion: AnyTypedQuizQuestion;
|
2023-12-15 12:12:36 +00:00
|
|
|
|
showContactForm: boolean;
|
|
|
|
|
|
setShowContactForm: (show: boolean) => void;
|
|
|
|
|
|
setShowResultForm: (show: boolean) => void;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const ResultForm = ({
|
2023-12-16 09:36:35 +00:00
|
|
|
|
currentQuestion,
|
2023-12-15 12:12:36 +00:00
|
|
|
|
showContactForm,
|
|
|
|
|
|
setShowContactForm,
|
|
|
|
|
|
setShowResultForm,
|
|
|
|
|
|
}: ResultFormProps) => {
|
|
|
|
|
|
const quiz = useCurrentQuiz();
|
2023-12-25 23:46:28 +00:00
|
|
|
|
const mode = modes;
|
2023-12-16 09:36:35 +00:00
|
|
|
|
const { questions } = useQuestionsStore();
|
2023-12-28 14:10:21 +00:00
|
|
|
|
const resultQuestion = (questions.find(
|
2023-12-16 09:36:35 +00:00
|
|
|
|
(question) =>
|
|
|
|
|
|
question.type === "result" &&
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question.content.rule.parentId === currentQuestion.content.id,
|
2023-12-28 14:10:21 +00:00
|
|
|
|
) ||
|
|
|
|
|
|
questions.find(
|
|
|
|
|
|
(question) =>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question.type === "result" && question.content.rule.parentId === "line",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
)) as AnyTypedQuizQuestion;
|
2023-12-16 20:52:01 +00:00
|
|
|
|
|
2023-12-15 12:12:36 +00:00
|
|
|
|
const followNextForm = () => {
|
|
|
|
|
|
setShowResultForm(false);
|
|
|
|
|
|
setShowContactForm(true);
|
|
|
|
|
|
};
|
2023-12-28 14:10:21 +00:00
|
|
|
|
if (resultQuestion === undefined) return <></>;
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
|
|
|
|
|
return (
|
2023-12-16 12:33:06 +00:00
|
|
|
|
<Box
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
display: "flex",
|
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
|
height: "100vh",
|
|
|
|
|
|
width: "100vw",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
pt: "28px",
|
2023-12-16 12:33:06 +00:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Box
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
display: "flex",
|
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
|
alignItems: "start",
|
|
|
|
|
|
width: "490px",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
2023-12-28 14:10:21 +00:00
|
|
|
|
{!resultQuestion?.content.useImage && resultQuestion.content.video && (
|
2023-12-16 12:33:06 +00:00
|
|
|
|
<YoutubeEmbedIframe
|
2023-12-16 15:59:36 +00:00
|
|
|
|
videoUrl={resultQuestion.content.video}
|
2023-12-16 12:33:06 +00:00
|
|
|
|
containerSX={{
|
|
|
|
|
|
width: "490px",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
height: "280px",
|
2023-12-16 12:33:06 +00:00
|
|
|
|
}}
|
|
|
|
|
|
/>
|
2023-12-28 14:10:21 +00:00
|
|
|
|
)}
|
|
|
|
|
|
{resultQuestion?.content.useImage && resultQuestion.content.back && (
|
2023-12-16 12:33:06 +00:00
|
|
|
|
<Box
|
2023-12-28 14:10:21 +00:00
|
|
|
|
component="img"
|
2023-12-16 15:59:36 +00:00
|
|
|
|
src={resultQuestion.content.back}
|
2023-12-16 12:33:06 +00:00
|
|
|
|
sx={{
|
|
|
|
|
|
width: "490px",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
height: "280px",
|
2023-12-16 12:33:06 +00:00
|
|
|
|
}}
|
2023-12-28 14:10:21 +00:00
|
|
|
|
></Box>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{resultQuestion.description !== "" &&
|
|
|
|
|
|
resultQuestion.description !== " " && (
|
|
|
|
|
|
<Typography
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
fontSize: "23px",
|
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{resultQuestion.description}
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
)}
|
2023-12-16 12:33:06 +00:00
|
|
|
|
|
2024-01-05 07:07:06 +00:00
|
|
|
|
{resultQuestion.title && (
|
2024-01-05 05:21:39 +00:00
|
|
|
|
<Typography
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{resultQuestion.title}
|
|
|
|
|
|
</Typography>
|
2024-01-05 07:07:06 +00:00
|
|
|
|
)}
|
2023-12-16 12:33:06 +00:00
|
|
|
|
|
2023-12-28 14:10:21 +00:00
|
|
|
|
{resultQuestion.content.text !== "" &&
|
|
|
|
|
|
resultQuestion.content.text !== " " && (
|
|
|
|
|
|
<Typography
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{resultQuestion.content.text}
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
)}
|
2023-12-16 12:33:06 +00:00
|
|
|
|
</Box>
|
|
|
|
|
|
|
2023-12-21 11:47:34 +00:00
|
|
|
|
<Box width="100%">
|
2023-12-16 20:17:42 +00:00
|
|
|
|
<Box
|
2023-12-16 12:33:06 +00:00
|
|
|
|
sx={{
|
2023-12-16 20:17:42 +00:00
|
|
|
|
display: "flex",
|
2023-12-21 11:47:34 +00:00
|
|
|
|
width: "100%",
|
|
|
|
|
|
justifyContent: "end",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
px: "20px",
|
2023-12-16 12:33:06 +00:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
2023-12-21 11:47:34 +00:00
|
|
|
|
<Box
|
2023-12-16 20:17:42 +00:00
|
|
|
|
sx={{
|
2023-12-21 11:47:34 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
|
alignItems: "center",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
mt: "15px",
|
2023-12-16 20:17:42 +00:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
2023-12-21 11:47:34 +00:00
|
|
|
|
<NameplateLogo style={{ fontSize: "34px" }} />
|
2023-12-28 14:10:21 +00:00
|
|
|
|
<Typography
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
fontSize: "20px",
|
|
|
|
|
|
color: mode[quiz.config.theme] ? "#4D4D4D" : "#F5F7FF",
|
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
Сделано на PenaQuiz
|
|
|
|
|
|
</Typography>
|
2023-12-21 11:47:34 +00:00
|
|
|
|
</Box>
|
2023-12-16 20:17:42 +00:00
|
|
|
|
</Box>
|
2023-12-21 11:47:34 +00:00
|
|
|
|
|
2023-12-28 14:10:21 +00:00
|
|
|
|
{quiz?.config.resultInfo.when === "before" && (
|
2023-12-21 11:47:34 +00:00
|
|
|
|
<>
|
|
|
|
|
|
<Box
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
boxShadow: "0 0 15px 0 rgba(0,0,0,.08)",
|
|
|
|
|
|
width: "100%",
|
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
|
display: "flex",
|
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
|
alignItems: "center",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
p: "20px",
|
2023-12-21 11:47:34 +00:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
onClick={followNextForm}
|
|
|
|
|
|
variant="contained"
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
p: "10px 20px",
|
|
|
|
|
|
width: "210px",
|
2023-12-28 14:10:21 +00:00
|
|
|
|
height: "50px",
|
2023-12-21 11:47:34 +00:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
</>
|
2023-12-28 14:10:21 +00:00
|
|
|
|
)}
|
2023-12-21 11:47:34 +00:00
|
|
|
|
</Box>
|
2023-12-15 12:12:36 +00:00
|
|
|
|
</Box>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|