From afb641c382f10bb5bcd3b2a2c6fbb46c0a1d38a5 Mon Sep 17 00:00:00 2001 From: aleksandr-raw <104529174+aleksandr-raw@users.noreply.github.com> Date: Wed, 8 May 2024 17:53:57 +0400 Subject: [PATCH] result page refactoring completed --- .../ViewPublicationPage/ResultForm.tsx | 525 +++++++++--------- 1 file changed, 268 insertions(+), 257 deletions(-) diff --git a/lib/components/ViewPublicationPage/ResultForm.tsx b/lib/components/ViewPublicationPage/ResultForm.tsx index 61b672d..f4c2224 100644 --- a/lib/components/ViewPublicationPage/ResultForm.tsx +++ b/lib/components/ViewPublicationPage/ResultForm.tsx @@ -1,275 +1,286 @@ -import { Box, Button, Link, Typography, useTheme } from "@mui/material"; +import {Box, Button, Link, Typography, useTheme} from "@mui/material"; -import { NameplateLogo } from "@icons/NameplateLogo"; +import {NameplateLogo} from "@icons/NameplateLogo"; import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe"; -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"; +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"; type ResultFormProps = { - resultQuestion: QuizQuestionResult; + resultQuestion: QuizQuestionResult; }; -export const ResultForm = ({ resultQuestion }: ResultFormProps) => { - const theme = useTheme(); - const isMobile = useRootContainerSize() < 650; - const isTablet = useRootContainerSize() < 1000; - const { settings, show_badge, quizId } = useQuizData(); - const setCurrentQuizStep = useQuizViewStore( - (state) => state.setCurrentQuizStep - ); - const spec = settings.cfg.spec; +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; - useEffect(() => { - //@ts-ignore - let YM = window?.ym; - //@ts-ignore - let 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}}` - }); - }; - }, []) + 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}}`, + }); + } + }, []); - return ( - - + return ( - - Ваш результат: - - - - {!resultQuestion?.content.useImage && - resultQuestion.content.video && ( - - )} - {resultQuestion?.content.useImage && resultQuestion.content.back && ( - + + + + Ваш результат: + + + + {!resultQuestion?.content.useImage && + resultQuestion.content.video && ( + + )} + {resultQuestion?.content.useImage && + resultQuestion.content.back && ( + + resultImage + + )} + {resultQuestion.description !== "" && + resultQuestion.description !== " " && ( + + {resultQuestion.description} + + )} + + + {resultQuestion.title} + + + {resultQuestion.content.text !== "" && + resultQuestion.content.text !== " " && ( + + {resultQuestion.content.text} + + )} + + + {show_badge && ( + + + + )} + + {settings.cfg.resultInfo.showResultForm === "before" && + !settings.cfg.score && ( + + )} + {settings.cfg.resultInfo.showResultForm === "after" && + resultQuestion.content.redirect && ( + + )} + - )} - {resultQuestion.description !== "" && - resultQuestion.description !== " " && ( - - {resultQuestion.description} - - )} - - - {resultQuestion.title} - - - {resultQuestion.content.text !== "" && - resultQuestion.content.text !== " " && ( - - {resultQuestion.content.text} - - )} - - - - {show_badge && ( - - - - - )} - - - - {settings.cfg.resultInfo.showResultForm === "before" && - !settings.cfg.score && ( - - )} - {settings.cfg.resultInfo.showResultForm === "after" && - resultQuestion.content.redirect && ( - - )} - - - - - ); + ); };