import { Box, Button, Typography, useTheme } from "@mui/material"; import { NameplateLogo } from "@icons/NameplateLogo"; import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe"; import { useQuizData } from "@utils/hooks/useQuizData"; import { quizThemes } from "@utils/themes/Publication/themePublication"; import { useCallback, useEffect, useMemo } from "react"; import { useRootContainerSize } from "../../contexts/RootContainerWidthContext"; import type { QuizQuestionResult } from "../../model/questionTypes/result"; type ResultFormProps = { currentQuestion: any; showContactForm: boolean; setShowContactForm: (show: boolean) => void; setShowResultForm: (show: boolean) => void; }; export const ResultForm = ({ currentQuestion, showContactForm, setShowContactForm, setShowResultForm, }: ResultFormProps) => { const theme = useTheme(); const isMobile = useRootContainerSize() < 650; const { settings, questions } = useQuizData(); const resultQuestion = useMemo(() => { if (settings?.cfg.haveRoot) { //ищём для ветвления return (questions.find( (question): question is QuizQuestionResult => question.type === "result" && question.content.rule.parentId === currentQuestion.content.id ) || questions.find( (question): question is QuizQuestionResult => question.type === "result" && question.content.rule.parentId === "line" )); } else { return questions.find( (question): question is QuizQuestionResult => question.type === "result" && question.content.rule.parentId === "line" ); } }, [currentQuestion.content.id, questions, settings?.cfg.haveRoot]); const followNextForm = useCallback(() => { setShowResultForm(false); setShowContactForm(true); }, [setShowContactForm, setShowResultForm]); useEffect(() => { if (!resultQuestion) { followNextForm(); } }, [followNextForm, resultQuestion]); if (!resultQuestion) return null; return ( { !resultQuestion?.content.useImage && resultQuestion.content.video && ( ) } { resultQuestion?.content.useImage && resultQuestion.content.back && ( ) } {resultQuestion.description !== "" && resultQuestion.description !== " " && ( {resultQuestion.description} )} {resultQuestion.title} { resultQuestion.content.text !== "" && resultQuestion.content.text !== " " && ( { resultQuestion.content.text } ) } Сделано на PenaQuiz {settings?.cfg.resultInfo.showResultForm === "before" && ( )} {settings?.cfg.resultInfo.showResultForm === "after" && resultQuestion.content.redirect && ( )} ); };