From 833b87319f7240ddeecb1987bfce51adbeba3be3 Mon Sep 17 00:00:00 2001 From: IlyaDoronin Date: Mon, 16 Oct 2023 12:35:04 +0300 Subject: [PATCH 1/5] fix: form steps --- src/pages/startPage/stepOne.tsx | 5 +---- src/ui_kit/switchStepPages.tsx | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/startPage/stepOne.tsx b/src/pages/startPage/stepOne.tsx index 5163a984..6ed63f28 100755 --- a/src/pages/startPage/stepOne.tsx +++ b/src/pages/startPage/stepOne.tsx @@ -44,10 +44,7 @@ export default function StepOne() { onClick={() => { let SPageClone = listQuizes[params].config; SPageClone.type = "form"; - updateQuizesList(params, { - config: SPageClone, - step: listQuizes[params].step + 1, - }); + updateQuizesList(params, { config: SPageClone }); }} > ; - if (quizType === "form") return <>; if (!startpage) return ; return ; case 2: From ba620de334c47fab6fecb7218346993c2a43cb68 Mon Sep 17 00:00:00 2001 From: IlyaDoronin Date: Mon, 16 Oct 2023 13:20:07 +0300 Subject: [PATCH 2/5] fix: removing question bug --- .../DraggableList/QuestionPageCard.tsx | 5 +- src/stores/questions.ts | 76 +++++++++---------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/pages/Questions/DraggableList/QuestionPageCard.tsx b/src/pages/Questions/DraggableList/QuestionPageCard.tsx index 078c96e6..9c2488d7 100644 --- a/src/pages/Questions/DraggableList/QuestionPageCard.tsx +++ b/src/pages/Questions/DraggableList/QuestionPageCard.tsx @@ -49,7 +49,10 @@ import { ArrowDownIcon } from "@icons/questionsPage/ArrowDownIcon"; import { ReactComponent as PlusIcon } from "../../../assets/icons/plus.svg"; import type { DraggableProvidedDragHandleProps } from "react-beautiful-dnd"; -import type { AnyQuizQuestion, QuizQuestionInitial } from "../../../model/questionTypes/shared"; +import type { + AnyQuizQuestion, + QuizQuestionInitial, +} from "../../../model/questionTypes/shared"; interface Props { totalIndex: number; diff --git a/src/stores/questions.ts b/src/stores/questions.ts index 64cf258d..55bf985c 100644 --- a/src/stores/questions.ts +++ b/src/stores/questions.ts @@ -26,7 +26,6 @@ import { QUIZ_QUESTION_VARIANT } from "../constants/variant"; import { QUIZ_QUESTION_VARIMG } from "../constants/varimg"; import { setAutoFreeze } from "immer"; - setAutoFreeze(false); interface QuestionStore { @@ -63,37 +62,40 @@ export const questionStore = create()( return state; }, - merge: (persistedState, currentState) => { - const state = persistedState as QuestionStore; + merge: (persistedState, currentState) => { + const state = persistedState as QuestionStore; - // replace blob urls with "" - Object.values(state.listQuestions).forEach(questions => { - questions.forEach(question => { - if (question.type === "page" && question.content.picture.startsWith("blob:")) { - question.content.picture = ""; - } - if (question.type === "images") { - question.content.variants.forEach(variant => { - if (variant.extendedText.startsWith("blob:")) { - variant.extendedText = ""; - } - }); - } - if (question.type === "varimg") { - question.content.variants.forEach(variant => { - if (variant.extendedText.startsWith("blob:")) { - variant.extendedText = ""; - } - }); - } - }); - }); + // replace blob urls with "" + Object.values(state.listQuestions).forEach((questions) => { + questions.forEach((question) => { + if ( + question.type === "page" && + question.content.picture.startsWith("blob:") + ) { + question.content.picture = ""; + } + if (question.type === "images") { + question.content.variants.forEach((variant) => { + if (variant.extendedText.startsWith("blob:")) { + variant.extendedText = ""; + } + }); + } + if (question.type === "varimg") { + question.content.variants.forEach((variant) => { + if (variant.extendedText.startsWith("blob:")) { + variant.extendedText = ""; + } + }); + } + }); + }); - return { - ...currentState, - ...state, - }; - }, + return { + ...currentState, + ...state, + }; + }, } ) ); @@ -191,13 +193,11 @@ export const createQuestion = ( export const copyQuestion = (quizId: number, copiedQuestionIndex: number) => { const listQuestions = { ...questionStore.getState()["listQuestions"] }; - const copiedQuiz = listQuestions[quizId][copiedQuestionIndex] - copiedQuiz.id = getRandom() - listQuestions[quizId].splice( - copiedQuestionIndex, - 0, - copiedQuiz - ); + const copiedQuiz = { ...listQuestions[quizId][copiedQuestionIndex] }; + listQuestions[quizId].splice(copiedQuestionIndex, 0, { + ...copiedQuiz, + id: getRandom(), + }); questionStore.setState({ listQuestions }); }; @@ -238,4 +238,4 @@ function getRandom() { const min = Math.ceil(1000000); const max = Math.floor(10000000); return Math.floor(Math.random() * (max - min)) + min; -} \ No newline at end of file +} From 4507c71ba05b64f074f0ed4916370d60cfa5b8a2 Mon Sep 17 00:00:00 2001 From: IlyaDoronin Date: Mon, 16 Oct 2023 15:57:37 +0300 Subject: [PATCH 3/5] fix: quize result page --- src/pages/Result/CreationFullCard.tsx | 62 +++++++++++++++++---------- src/pages/Result/Result.tsx | 18 ++++---- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/src/pages/Result/CreationFullCard.tsx b/src/pages/Result/CreationFullCard.tsx index bfc62d82..ebef6ed7 100644 --- a/src/pages/Result/CreationFullCard.tsx +++ b/src/pages/Result/CreationFullCard.tsx @@ -1,4 +1,4 @@ -import { Box, Typography } from "@mui/material"; +import { Box, Typography, useTheme, useMediaQuery } from "@mui/material"; type Props = { text: string; @@ -7,14 +7,20 @@ type Props = { }; export default function CreationFullCard({ text, text2, image }: Props) { + const theme = useTheme(); + const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1500)); + return ( - - Результаты квиза в зависимости от ответов - + + Результаты квиза в зависимости от ответов + + - {text} - - - {text2} - + + {text} + + + {text2} + + quiz creation diff --git a/src/pages/Result/Result.tsx b/src/pages/Result/Result.tsx index 621a73d5..74bfcd8d 100644 --- a/src/pages/Result/Result.tsx +++ b/src/pages/Result/Result.tsx @@ -1,5 +1,5 @@ -import { Link, useParams } from "react-router-dom"; -import { Box, Button, useTheme } from "@mui/material"; +import { useParams } from "react-router-dom"; +import { Box, Button, Tooltip, useTheme } from "@mui/material"; import CreationFullCard from "./CreationFullCard"; import Info from "../../assets/icons/Info"; @@ -21,19 +21,19 @@ export const Result = () => { text2="Этот шаг - необязательный, квиз будет работать и без автоматических результатов." image={image} /> - + - - + + + + + ); From 7b052ddd96bc948677d0b4934ce65e5ad4525834 Mon Sep 17 00:00:00 2001 From: IlyaDoronin Date: Mon, 16 Oct 2023 17:23:44 +0300 Subject: [PATCH 4/5] fix: result styles --- .../DescriptionForm/DescriptionForm.tsx | 21 +++- .../DescriptionForm/DiscountButtons.tsx | 5 +- .../Result/DescriptionForm/PriceButton.tsx | 110 ++++++++++-------- src/pages/Result/ResultListForm.tsx | 20 +++- src/pages/Result/Setting.tsx | 59 ++++++---- src/pages/Result/SettingForm.tsx | 77 ++++++++++-- src/ui_kit/CustomWrapper.tsx | 2 +- 7 files changed, 201 insertions(+), 93 deletions(-) diff --git a/src/pages/Result/DescriptionForm/DescriptionForm.tsx b/src/pages/Result/DescriptionForm/DescriptionForm.tsx index a0c84f05..3ff90205 100644 --- a/src/pages/Result/DescriptionForm/DescriptionForm.tsx +++ b/src/pages/Result/DescriptionForm/DescriptionForm.tsx @@ -31,7 +31,7 @@ export const DescriptionForm = () => { return ( { - + @@ -85,7 +88,10 @@ export const DescriptionForm = () => { {priceButtonsType === "smooth" ? ( - + Призыв к действию @@ -127,8 +133,13 @@ export const DescriptionForm = () => { {forwarding ? ( - - + + Переадресация diff --git a/src/pages/Result/DescriptionForm/DiscountButtons.tsx b/src/pages/Result/DescriptionForm/DiscountButtons.tsx index 149e1cac..07213f59 100644 --- a/src/pages/Result/DescriptionForm/DiscountButtons.tsx +++ b/src/pages/Result/DescriptionForm/DiscountButtons.tsx @@ -14,7 +14,10 @@ export default function DiscountButtons() { - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + diff --git a/src/pages/Result/SettingForm.tsx b/src/pages/Result/SettingForm.tsx index 1242b1ff..af49f3c5 100644 --- a/src/pages/Result/SettingForm.tsx +++ b/src/pages/Result/SettingForm.tsx @@ -1,5 +1,14 @@ import { useState } from "react"; -import { Box, Button, IconButton, SxProps, Theme, Typography } from "@mui/material"; +import { + Box, + Button, + IconButton, + SxProps, + Theme, + Typography, + useTheme, + useMediaQuery, +} from "@mui/material"; import { SwitchSetting } from "./SwichResult"; import Info from "@icons/Info"; @@ -10,17 +19,35 @@ import ArrowCounterClockWise from "@icons/ArrowCounterClockWise.svg"; const buttonSetting: { title: string; sx: SxProps; type: string }[] = [ { - sx: { backgroundColor: "#7E2AEA", color: "white", width: "237px", height: "44px", border: "1px solid #9A9AAF" }, + sx: { + backgroundColor: "#7E2AEA", + color: "white", + width: "237px", + height: "44px", + border: "1px solid #9A9AAF", + }, title: "До формы контактов", type: "toContactForm", }, { - sx: { backgroundColor: "#F2F3F7", color: "#9A9AAF", width: "266px", height: "44px", border: "1px solid #9A9AAF" }, + sx: { + backgroundColor: "#F2F3F7", + color: "#9A9AAF", + width: "266px", + height: "44px", + border: "1px solid #9A9AAF", + }, title: "После формы контактов", type: "afterСontactForm", }, { - sx: { color: "#9A9AAF", backgroundColor: "#F2F3F7", width: "233px", height: "44px", border: "1px solid #9A9AAF" }, + sx: { + color: "#9A9AAF", + backgroundColor: "#F2F3F7", + width: "233px", + height: "44px", + border: "1px solid #9A9AAF", + }, title: "Отправить на E-mail", type: "e-mail", }, @@ -29,6 +56,8 @@ const buttonSetting: { title: string; sx: SxProps; type: string }[] = [ export const SettingForm = () => { const [activeIndex, setActiveIndex] = useState(0); const [typeActive, setTypeActive] = useState("toContactForm"); + const theme = useTheme(); + const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1100)); const active = (index: number, type: string) => { setActiveIndex(index); @@ -36,7 +65,7 @@ export const SettingForm = () => { }; return ( - + Настройки результатов @@ -63,7 +92,13 @@ export const SettingForm = () => { Показывать результат - + { - + {buttonSetting.map(({ sx, title, type }, index) => (