2024-05-08 13:53:57 +00:00
|
|
|
|
import {Box, Button, Link, Typography, useTheme} from "@mui/material";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-05-08 13:53:57 +00:00
|
|
|
|
import {NameplateLogo} from "@icons/NameplateLogo";
|
2024-01-30 16:49:33 +00:00
|
|
|
|
import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-05-08 13:53:57 +00:00
|
|
|
|
import {useQuizData} from "@contexts/QuizDataContext";
|
|
|
|
|
import {quizThemes} from "@utils/themes/Publication/themePublication";
|
|
|
|
|
import {useRootContainerSize} from "../../contexts/RootContainerWidthContext";
|
|
|
|
|
import type {QuizQuestionResult} from "../../model/questionTypes/result";
|
|
|
|
|
import {useQuizViewStore} from "@/stores/quizView";
|
|
|
|
|
import {DESIGN_LIST} from "@/utils/designList";
|
|
|
|
|
import {useEffect} from "react";
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2023-12-16 14:55:56 +00:00
|
|
|
|
type ResultFormProps = {
|
2024-05-08 13:53:57 +00:00
|
|
|
|
resultQuestion: QuizQuestionResult;
|
2023-12-16 14:55:56 +00:00
|
|
|
|
};
|
2024-02-08 13:42:31 +00:00
|
|
|
|
|
2024-05-08 13:53:57 +00:00
|
|
|
|
export const ResultForm = ({resultQuestion}: ResultFormProps) => {
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useRootContainerSize() < 650;
|
|
|
|
|
const isTablet = useRootContainerSize() < 1100;
|
|
|
|
|
const {settings, show_badge, quizId} = useQuizData();
|
|
|
|
|
const setCurrentQuizStep = useQuizViewStore(
|
|
|
|
|
(state) => state.setCurrentQuizStep,
|
|
|
|
|
);
|
|
|
|
|
const spec = settings.cfg.spec;
|
2024-05-05 22:07:15 +00:00
|
|
|
|
|
2024-05-08 13:53:57 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
const YM = window?.ym;
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
const VP = window?._tmr;
|
|
|
|
|
if (YM !== undefined && settings.cfg.yandexMetricNumber !== undefined) {
|
|
|
|
|
YM(
|
|
|
|
|
settings.cfg.yandexMetricNumber,
|
|
|
|
|
"reachGoal",
|
|
|
|
|
`penaquiz-result-{${resultQuestion.id}}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (VP !== undefined && settings.cfg.vkMetricNumber !== undefined) {
|
|
|
|
|
VP.push({
|
|
|
|
|
type: "reachGoal",
|
|
|
|
|
id: settings.cfg.vkMetricNumber,
|
|
|
|
|
goal: `penaquiz-result-{${resultQuestion.id}}`,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-05-08 13:53:57 +00:00
|
|
|
|
return (
|
2023-12-17 13:22:21 +00:00
|
|
|
|
<Box
|
2024-01-30 16:49:33 +00:00
|
|
|
|
sx={{
|
2024-05-08 13:53:57 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
height: "100%",
|
|
|
|
|
minHeight: "100%",
|
|
|
|
|
width: "100%",
|
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
|
backgroundPosition: "center",
|
|
|
|
|
backgroundSize: "cover",
|
|
|
|
|
backgroundImage:
|
|
|
|
|
settings.cfg.design && !isMobile
|
|
|
|
|
? `url(${DESIGN_LIST[settings.cfg.theme]})`
|
|
|
|
|
: null,
|
|
|
|
|
position: "relative",
|
2024-03-14 17:17:19 +00:00
|
|
|
|
}}
|
2023-12-17 13:22:21 +00:00
|
|
|
|
>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
<Box
|
2024-04-17 13:27:29 +00:00
|
|
|
|
sx={{
|
2024-05-08 13:53:57 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
width: "100%",
|
|
|
|
|
height: "100%",
|
|
|
|
|
background:
|
|
|
|
|
settings.cfg.design && !isMobile
|
|
|
|
|
? quizThemes[settings.cfg.theme].isLight
|
|
|
|
|
? "transparent"
|
|
|
|
|
: "linear-gradient(90deg, rgba(39, 38, 38, 0.95) 7.66%, rgba(42, 42, 46, 0.85) 42.12%, rgba(51, 54, 71, 0.4) 100%)"
|
|
|
|
|
: theme.palette.background.default,
|
2024-04-17 13:27:29 +00:00
|
|
|
|
}}
|
2024-05-08 13:53:57 +00:00
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
width: "100%",
|
|
|
|
|
height: "100%",
|
|
|
|
|
overflow: "auto",
|
|
|
|
|
padding: "0 20px 20px",
|
|
|
|
|
scrollbarWidth: "none",
|
|
|
|
|
"&::-webkit-scrollbar": {
|
|
|
|
|
width: 0,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
flexWrap: "wrap",
|
|
|
|
|
mb: "10px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "700px",
|
|
|
|
|
backgroundColor: "#9A9AAF1A",
|
|
|
|
|
borderRadius: "0 0 12px 12px",
|
|
|
|
|
padding: "20px 20px 15px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "17px",
|
|
|
|
|
color: "#9A9AAF",
|
|
|
|
|
wordBreak: "break-word",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Ваш результат:
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "flex-start",
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "700px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{!resultQuestion?.content.useImage &&
|
|
|
|
|
resultQuestion.content.video && (
|
|
|
|
|
<YoutubeEmbedIframe
|
|
|
|
|
videoUrl={resultQuestion.content.video}
|
|
|
|
|
containerSX={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "700px",
|
|
|
|
|
height: isMobile ? "100%" : "306px",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{resultQuestion?.content.useImage &&
|
|
|
|
|
resultQuestion.content.back && (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
alt="resultImage"
|
|
|
|
|
src={resultQuestion.content.back}
|
|
|
|
|
style={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
height: spec ? "auto" : isMobile ? "236px" : "306px",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
objectFit: "cover",
|
|
|
|
|
overflow: "hidden",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
{resultQuestion.description !== "" &&
|
|
|
|
|
resultQuestion.description !== " " && (
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "27px",
|
|
|
|
|
lineHeight: "32px",
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
mt: "30px",
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
wordBreak: "break-word",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.description}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
2024-05-04 21:33:57 +00:00
|
|
|
|
|
2024-05-08 13:53:57 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
mt: "12px",
|
|
|
|
|
fontSize: "17px",
|
|
|
|
|
lineHeight: "20px",
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
wordBreak: "break-word",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.title}
|
|
|
|
|
</Typography>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2024-05-08 13:53:57 +00:00
|
|
|
|
{resultQuestion.content.text !== "" &&
|
|
|
|
|
resultQuestion.content.text !== " " && (
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "17px",
|
|
|
|
|
lineHeight: "20px",
|
|
|
|
|
mt: "25px ",
|
|
|
|
|
wordBreak: "break-word",
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.content.text}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
{show_badge && (
|
|
|
|
|
<Box
|
|
|
|
|
component={Link}
|
|
|
|
|
target={"_blank"}
|
|
|
|
|
href={`https://${
|
|
|
|
|
window.location.hostname.includes("s") ? "s" : ""
|
|
|
|
|
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
alignSelf: isMobile ? "center" : "end",
|
|
|
|
|
margin: isMobile ? "15px 0 0" : "15px 25px 0 0",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
textDecoration: "none",
|
|
|
|
|
mb: "15px",
|
|
|
|
|
position: isTablet || isMobile ? "sticky" : "absolute",
|
|
|
|
|
bottom: "90px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<NameplateLogo
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: "23px",
|
|
|
|
|
color: quizThemes[settings.cfg.theme].isLight
|
|
|
|
|
? "#000000"
|
|
|
|
|
: "#F5F7FF",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
borderTop: "1px solid #9A9AAF80",
|
|
|
|
|
p: "20px",
|
|
|
|
|
position: "sticky",
|
|
|
|
|
bottom: 0,
|
|
|
|
|
}}
|
2024-04-17 13:27:29 +00:00
|
|
|
|
>
|
2024-05-08 13:53:57 +00:00
|
|
|
|
{settings.cfg.resultInfo.showResultForm === "before" &&
|
|
|
|
|
!settings.cfg.score && (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => setCurrentQuizStep("contactform")}
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
p: "10px 20px",
|
|
|
|
|
width: "auto",
|
|
|
|
|
height: "50px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
{settings.cfg.resultInfo.showResultForm === "after" &&
|
|
|
|
|
resultQuestion.content.redirect && (
|
|
|
|
|
<Button
|
|
|
|
|
href={
|
|
|
|
|
resultQuestion.content.redirect.includes("https")
|
|
|
|
|
? resultQuestion.content.redirect
|
|
|
|
|
: `https://${resultQuestion.content.redirect}`
|
|
|
|
|
}
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
p: "10px 20px",
|
|
|
|
|
width: "auto",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.content.hint.text || "Перейти на сайт"}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
</Box>
|
2024-05-08 13:53:57 +00:00
|
|
|
|
);
|
2024-01-10 18:02:37 +00:00
|
|
|
|
};
|