fix: publication result logic

This commit is contained in:
IlyaDoronin 2023-12-28 17:10:21 +03:00
parent 60145514e2
commit ceaab812a6

@ -5,9 +5,9 @@ import { useCurrentQuiz } from "@root/quizes/hooks";
import { useQuestionsStore } from "@root/questions/store"; import { useQuestionsStore } from "@root/questions/store";
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared"; import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx" import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx";
import { NameplateLogo } from "@icons/NameplateLogo"; import { NameplateLogo } from "@icons/NameplateLogo";
import {modes} from "../../utils/themes/Publication/themePublication"; import { modes } from "../../utils/themes/Publication/themePublication";
type ResultFormProps = { type ResultFormProps = {
currentQuestion: AnyTypedQuizQuestion; currentQuestion: AnyTypedQuizQuestion;
@ -21,25 +21,25 @@ export const ResultForm = ({
showContactForm, showContactForm,
setShowContactForm, setShowContactForm,
setShowResultForm, setShowResultForm,
}: ResultFormProps) => { }: ResultFormProps) => {
const quiz = useCurrentQuiz(); const quiz = useCurrentQuiz();
const mode = modes; const mode = modes;
const { questions } = useQuestionsStore(); const { questions } = useQuestionsStore();
const resultQuestion = questions.find( const resultQuestion = (questions.find(
(question) => (question) =>
question.type === "result" && question.type === "result" &&
(question.content.rule.parentId === "line" || currentQuestion.content.id) question.content.rule.parentId === currentQuestion.content.id
); ) ||
questions.find(
(question) =>
question.type === "result" && question.content.rule.parentId === "line"
)) as AnyTypedQuizQuestion;
const followNextForm = () => { const followNextForm = () => {
setShowResultForm(false); setShowResultForm(false);
setShowContactForm(true); setShowContactForm(true);
}; };
if (resultQuestion === undefined) return <></> if (resultQuestion === undefined) return <></>;
return ( return (
<Box <Box
@ -50,10 +50,9 @@ export const ResultForm = ({
justifyContent: "space-between", justifyContent: "space-between",
height: "100vh", height: "100vh",
width: "100vw", width: "100vw",
pt: "28px" pt: "28px",
}} }}
> >
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
@ -62,53 +61,57 @@ export const ResultForm = ({
width: "490px", width: "490px",
}} }}
> >
{ {!resultQuestion?.content.useImage && resultQuestion.content.video && (
!resultQuestion?.content.useImage &&
resultQuestion.content.video &&
<YoutubeEmbedIframe <YoutubeEmbedIframe
videoUrl={resultQuestion.content.video} videoUrl={resultQuestion.content.video}
containerSX={{ containerSX={{
width: "490px", width: "490px",
height: "280px" height: "280px",
}} }}
/> />
} )}
{ {resultQuestion?.content.useImage && resultQuestion.content.back && (
resultQuestion?.content.useImage &&
resultQuestion.content.back &&
<Box <Box
component='img' component="img"
src={resultQuestion.content.back} src={resultQuestion.content.back}
sx={{ sx={{
width: "490px", width: "490px",
height: "280px" height: "280px",
}} }}
> ></Box>
</Box> )}
} {resultQuestion.description !== "" &&
{resultQuestion.description !== "" && resultQuestion.description !== " " && <Typography resultQuestion.description !== " " && (
sx={{ <Typography
fontSize: "23px", sx={{
fontWeight: 700, fontSize: "23px",
m: "20px 0" fontWeight: 700,
}} m: "20px 0",
>{resultQuestion.description}</Typography>} }}
>
{resultQuestion.description}
</Typography>
)}
<Typography <Typography
sx={{ sx={{
m: "20px 0" m: "20px 0",
}} }}
>{resultQuestion.title || "Форма результатов"} >
{resultQuestion.title || "Форма результатов"}
</Typography> </Typography>
{resultQuestion.content.text !== "" && resultQuestion.content.text !== " " && <Typography {resultQuestion.content.text !== "" &&
sx={{ resultQuestion.content.text !== " " && (
fontSize: "18px", <Typography
m: "20px 0" sx={{
}} fontSize: "18px",
>{resultQuestion.content.text}</Typography>} m: "20px 0",
}}
>
{resultQuestion.content.text}
</Typography>
)}
</Box> </Box>
<Box width="100%"> <Box width="100%">
@ -117,24 +120,30 @@ export const ResultForm = ({
display: "flex", display: "flex",
width: "100%", width: "100%",
justifyContent: "end", justifyContent: "end",
px: "20px" px: "20px",
}} }}
> >
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
mt: "15px" mt: "15px",
}} }}
> >
<NameplateLogo style={{ fontSize: "34px" }} /> <NameplateLogo style={{ fontSize: "34px" }} />
<Typography sx={{ fontSize: "20px", color: mode[quiz.config.theme] ? "#4D4D4D" : "#F5F7FF", whiteSpace: "nowrap" }}>Сделано на PenaQuiz</Typography> <Typography
sx={{
fontSize: "20px",
color: mode[quiz.config.theme] ? "#4D4D4D" : "#F5F7FF",
whiteSpace: "nowrap",
}}
>
Сделано на PenaQuiz
</Typography>
</Box> </Box>
</Box> </Box>
{ {quiz?.config.resultInfo.when === "before" && (
quiz?.config.resultInfo.when === "before" &&
<> <>
<Box <Box
sx={{ sx={{
@ -144,7 +153,7 @@ export const ResultForm = ({
display: "flex", display: "flex",
justifyContent: "center", justifyContent: "center",
alignItems: "center", alignItems: "center",
p: "20px" p: "20px",
}} }}
> >
<Button <Button
@ -153,17 +162,15 @@ export const ResultForm = ({
sx={{ sx={{
p: "10px 20px", p: "10px 20px",
width: "210px", width: "210px",
height: "50px" height: "50px",
}} }}
> >
{resultQuestion.content.hint.text || "Узнать подробнее"} {resultQuestion.content.hint.text || "Узнать подробнее"}
</Button> </Button>
</Box> </Box>
</> </>
} )}
</Box> </Box>
</Box> </Box>
); );
}; };