2024-01-10 18:02:37 +00:00
|
|
|
|
import {
|
2024-01-30 16:49:33 +00:00
|
|
|
|
Box,
|
2024-02-11 19:48:59 +00:00
|
|
|
|
Button, Link,
|
2024-01-30 16:49:33 +00:00
|
|
|
|
Typography,
|
2024-02-05 10:10:02 +00:00
|
|
|
|
useTheme
|
2024-01-10 18:02:37 +00:00
|
|
|
|
} from "@mui/material";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-04-03 12:42:12 +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-04-03 12:42:12 +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";
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2023-12-16 14:55:56 +00:00
|
|
|
|
type ResultFormProps = {
|
2024-02-08 13:42:31 +00:00
|
|
|
|
resultQuestion: QuizQuestionResult;
|
2023-12-16 14:55:56 +00:00
|
|
|
|
};
|
2024-02-08 13:42:31 +00:00
|
|
|
|
|
2024-04-03 12:42:12 +00:00
|
|
|
|
export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
2024-01-30 16:49:33 +00:00
|
|
|
|
const theme = useTheme();
|
2024-02-05 10:10:02 +00:00
|
|
|
|
const isMobile = useRootContainerSize() < 650;
|
2024-03-07 20:52:54 +00:00
|
|
|
|
const isTablet = useRootContainerSize() < 1000;
|
2024-04-03 12:42:12 +00:00
|
|
|
|
const { settings, show_badge, quizId } = useQuizData();
|
|
|
|
|
const setCurrentQuizStep = useQuizViewStore(state => state.setCurrentQuizStep);
|
|
|
|
|
const spec = settings.cfg.spec;
|
|
|
|
|
console.log(quizThemes[settings.cfg.theme].isLight);
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2023-12-17 13:22:21 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
2024-01-30 16:49:33 +00:00
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between",
|
2024-02-08 13:42:31 +00:00
|
|
|
|
height: "100%",
|
2024-04-02 17:21:31 +00:00
|
|
|
|
minHeight: "100%",
|
2024-02-19 14:58:59 +00:00
|
|
|
|
width: "100%",
|
2024-02-22 13:18:45 +00:00
|
|
|
|
backgroundColor: theme.palette.background.default,
|
2024-03-07 20:52:54 +00:00
|
|
|
|
backgroundPosition: "center",
|
|
|
|
|
backgroundSize: "cover",
|
2024-03-14 17:17:19 +00:00
|
|
|
|
backgroundImage: settings.cfg.design && !isMobile
|
2024-03-07 20:52:54 +00:00
|
|
|
|
? `url(${DESIGN_LIST[settings.cfg.theme]})`
|
|
|
|
|
: null,
|
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
|
2023-12-29 00:58:19 +00:00
|
|
|
|
sx={{
|
2024-01-30 16:49:33 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
2024-03-14 17:17:19 +00:00
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
pt: "30px",
|
2024-04-09 19:52:45 +00:00
|
|
|
|
width: "100%",
|
|
|
|
|
height: "100%",
|
|
|
|
|
overflow: "auto",
|
2024-03-20 00:00:54 +00:00
|
|
|
|
background: settings.cfg.design && !isMobile
|
2024-03-14 17:17:19 +00:00
|
|
|
|
? quizThemes[settings.cfg.theme].isLight
|
|
|
|
|
? "transparent"
|
|
|
|
|
: "linear-gradient(90deg,#272626, transparent)"
|
|
|
|
|
: theme.palette.background.default,
|
2024-04-17 00:02:08 +00:00
|
|
|
|
scrollbarWidth: "none",
|
|
|
|
|
"&::-webkit-scrollbar": {
|
|
|
|
|
width: 0,
|
|
|
|
|
},
|
2023-12-29 00:58:19 +00:00
|
|
|
|
}}
|
2024-01-30 16:49:33 +00:00
|
|
|
|
>
|
2024-03-20 00:00:54 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
flexWrap: "wrap",
|
|
|
|
|
gap: "30px",
|
|
|
|
|
mb: "7px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-03-20 02:09:44 +00:00
|
|
|
|
{settings.cfg.startpage.logo &&
|
2024-04-03 12:42:12 +00:00
|
|
|
|
<img
|
|
|
|
|
src={settings.cfg.startpage.logo}
|
|
|
|
|
style={{
|
|
|
|
|
height: "40px",
|
|
|
|
|
maxWidth: "110px",
|
|
|
|
|
objectFit: "cover",
|
|
|
|
|
}}
|
|
|
|
|
alt=""
|
|
|
|
|
/>
|
2024-03-20 02:09:44 +00:00
|
|
|
|
}
|
2024-03-20 00:00:54 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "14px",
|
2024-04-09 23:57:31 +00:00
|
|
|
|
color: theme.palette.text.primary,
|
2024-03-20 00:00:54 +00:00
|
|
|
|
wordBreak: "break-word",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{settings.cfg.info.orgname}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2024-03-14 17:17:19 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "flex-start",
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "844px",
|
|
|
|
|
padding: isMobile ? "0 16px" : isTablet ? "0 78px" : undefined,
|
|
|
|
|
}}>
|
|
|
|
|
{
|
|
|
|
|
!resultQuestion?.content.useImage && resultQuestion.content.video && (
|
|
|
|
|
<YoutubeEmbedIframe
|
|
|
|
|
videoUrl={resultQuestion.content.video}
|
|
|
|
|
containerSX={{
|
2024-03-20 00:00:54 +00:00
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "844px",
|
|
|
|
|
height: isMobile ? "100%" : "306px",
|
2024-03-14 17:17:19 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
resultQuestion?.content.useImage && resultQuestion.content.back && (
|
2024-04-08 23:38:44 +00:00
|
|
|
|
<Box sx={{width: "100%", display: "flex", justifyContent: "center"}}>
|
|
|
|
|
<Box
|
|
|
|
|
component="img"
|
|
|
|
|
src={resultQuestion.content.back}
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "306px",
|
|
|
|
|
height: spec ? "auto" : isMobile ? "236px" : "306px",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
objectFit: "contain",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
|
2024-03-14 17:17:19 +00:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
{resultQuestion.description !== "" &&
|
2024-04-03 12:42:12 +00:00
|
|
|
|
resultQuestion.description !== " " && (
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "23px",
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
wordBreak: "break-word"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.description}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
2024-03-14 17:17:19 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
wordBreak: "break-word"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.title}
|
|
|
|
|
</Typography>
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
2024-03-14 17:17:19 +00:00
|
|
|
|
{
|
|
|
|
|
resultQuestion.content.text !== "" &&
|
|
|
|
|
resultQuestion.content.text !== " " && (
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
wordBreak: "break-word",
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
resultQuestion.content.text
|
|
|
|
|
}
|
|
|
|
|
</Typography>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</Box>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
|
2024-03-14 17:17:19 +00:00
|
|
|
|
|
|
|
|
|
<Box width="100%">
|
2024-01-30 16:49:33 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
2024-03-14 17:17:19 +00:00
|
|
|
|
width: "100%",
|
|
|
|
|
justifyContent: "end",
|
|
|
|
|
px: "20px",
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-03-14 17:17:19 +00:00
|
|
|
|
{show_badge &&
|
2024-04-03 12:42:12 +00:00
|
|
|
|
<Box
|
|
|
|
|
component={Link}
|
|
|
|
|
target={"_blank"}
|
|
|
|
|
href={
|
|
|
|
|
`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`
|
|
|
|
|
}
|
2024-03-14 17:17:19 +00:00
|
|
|
|
sx={{
|
2024-04-03 12:42:12 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
mt: "15px",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
textDecoration: "none",
|
|
|
|
|
mb: "15px"
|
2024-03-14 17:17:19 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-04-03 12:42:12 +00:00
|
|
|
|
<NameplateLogo
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: "23px",
|
|
|
|
|
color: quizThemes[settings.cfg.theme].isLight ? "#000000" : "#F5F7FF",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
color: quizThemes[settings.cfg.theme].isLight ? "#4D4D4D" : "#F5F7FF",
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Сделано на PenaQuiz
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2024-03-14 17:17:19 +00:00
|
|
|
|
}
|
2024-03-02 15:33:28 +00:00
|
|
|
|
|
2024-03-14 17:17:19 +00:00
|
|
|
|
</Box>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2024-02-12 00:54:12 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
2024-03-14 16:09:40 +00:00
|
|
|
|
// boxShadow: "0 0 15px 0 rgba(0,0,0,.08)",
|
2024-02-12 00:54:12 +00:00
|
|
|
|
width: "100%",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center",
|
2024-03-20 00:00:54 +00:00
|
|
|
|
borderTop: "1px solid #9A9AAF80",
|
2024-03-14 17:17:19 +00:00
|
|
|
|
p:
|
|
|
|
|
(
|
|
|
|
|
settings.cfg.resultInfo.showResultForm === "before" &&
|
2024-04-03 12:42:12 +00:00
|
|
|
|
!settings.cfg.score
|
2024-03-14 17:17:19 +00:00
|
|
|
|
) ||
|
2024-04-03 12:42:12 +00:00
|
|
|
|
(
|
|
|
|
|
settings.cfg.resultInfo.showResultForm === "after" &&
|
|
|
|
|
resultQuestion.content.redirect
|
|
|
|
|
)
|
2024-03-14 17:17:19 +00:00
|
|
|
|
? "20px" : "0",
|
2024-02-12 00:54:12 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-04-03 12:42:12 +00:00
|
|
|
|
{settings.cfg.resultInfo.showResultForm === "before" && !settings.cfg.score && (
|
2024-01-30 16:49:33 +00:00
|
|
|
|
<Button
|
2024-02-12 00:54:12 +00:00
|
|
|
|
onClick={() => setCurrentQuizStep("contactform")}
|
2024-01-30 16:49:33 +00:00
|
|
|
|
variant="contained"
|
2024-02-12 00:54:12 +00:00
|
|
|
|
sx={{
|
|
|
|
|
p: "10px 20px",
|
|
|
|
|
width: "auto",
|
|
|
|
|
height: "50px",
|
|
|
|
|
}}
|
2024-01-30 16:49:33 +00:00
|
|
|
|
>
|
2024-02-12 00:54:12 +00:00
|
|
|
|
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
2024-01-30 16:49:33 +00:00
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2024-02-12 00:54:12 +00:00
|
|
|
|
{settings.cfg.resultInfo.showResultForm === "after" &&
|
2024-04-03 12:42:12 +00:00
|
|
|
|
resultQuestion.content.redirect && (
|
|
|
|
|
<Button
|
|
|
|
|
href={resultQuestion.content.redirect}
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{ p: "10px 20px", width: "auto", height: "50px" }}
|
|
|
|
|
>
|
|
|
|
|
{resultQuestion.content.hint.text || "Перейти на сайт"}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2024-02-12 00:54:12 +00:00
|
|
|
|
</Box>
|
2024-03-14 17:17:19 +00:00
|
|
|
|
</Box>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
</Box>
|
2023-12-21 19:22:06 +00:00
|
|
|
|
</Box>
|
2023-12-17 13:22:21 +00:00
|
|
|
|
);
|
2024-01-10 18:02:37 +00:00
|
|
|
|
};
|