From 719402c2b10b549f4474f8f6d1a282911ffa7817 Mon Sep 17 00:00:00 2001 From: Nastya Date: Sat, 9 Dec 2023 17:52:03 +0300 Subject: [PATCH] =?UTF-8?q?=D1=85=D0=B5=D0=BB=D0=BF=D0=B5=D1=80=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=83=D1=87=D0=B8=D1=82=D1=8B=D0=B2=D0=B0=D0=B5=D1=82?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=20=D0=B8=20=D0=B1?= =?UTF-8?q?=D0=B5=D0=B7=D1=82=D0=B8=D0=BF=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=B2?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=BE=D1=81=D1=8B,=20CS=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=20=D0=BD=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=83=D1=87=D0=B0=D0=B5=D1=82=20=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=D1=83=D0=BB=D1=8C=D1=82=20=D0=B8=20=D0=B1=D0=B5=D0=B7=D1=82?= =?UTF-8?q?=D0=B8=D0=BF=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=B2=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Questions/BranchingMap/CsComponent.tsx | 10 ++++++---- src/pages/Questions/QuestionSwitchWindowTool.tsx | 3 +-- src/pages/ResultPage/FirstEntry.tsx | 3 ++- src/pages/ResultPage/ResultSettings.tsx | 1 + src/stores/questions/actions.ts | 1 + 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx index 008cc82d..fcf2367b 100644 --- a/src/pages/Questions/BranchingMap/CsComponent.tsx +++ b/src/pages/Questions/BranchingMap/CsComponent.tsx @@ -20,9 +20,7 @@ import type { AbstractEventObject, ElementDefinition, } from "cytoscape"; -import { QuestionsList } from "../SwitchBranchingPanel/QuestionsList"; import { enqueueSnackbar } from "notistack"; -import { Typography } from "@mui/material"; type PopperItem = { id: () => string; @@ -124,7 +122,7 @@ function CsComponent ({ const { dragQuestionContentId, desireToOpenABranchingModal } = useQuestionsStore() const trashQuestions = useQuestionsStore().questions - const questions = trashQuestions.filter((question) => question.type !== "result") + const questions = trashQuestions.filter((question) => question.type !== "result" && question.type !== null) const [startCreate, setStartCreate] = useState(""); const [startRemove, setStartRemove] = useState(""); @@ -266,6 +264,10 @@ function CsComponent ({ cy?.layout(lyopts).run() } const clearDataAfterRemoveNode = ({ targetQuestionContentId, parentQuestionContentId }: { targetQuestionContentId: string, parentQuestionContentId: string }) => { + + console.log("target ",targetQuestionContentId, "parent ", parentQuestionContentId) + + updateQuestion(targetQuestionContentId, question => { question.content.rule.parentId = "" question.content.rule.main = [] @@ -421,7 +423,7 @@ function CsComponent ({ useEffect(() => { document.querySelector("#root")?.addEventListener("mouseup", cleardragQuestionContentId); const cy = cyRef.current; - const eles = cy?.add(storeToNodes(questions)) + const eles = cy?.add(storeToNodes(questions.filter((question:AnyTypedQuizQuestion) => (question.type !== "result" && question.type !== null)))) cy.data('changed', true) // cy.data('changed', true) const elecs = eles.layout(lyopts).run() diff --git a/src/pages/Questions/QuestionSwitchWindowTool.tsx b/src/pages/Questions/QuestionSwitchWindowTool.tsx index f7531dbb..7bbc2e3f 100644 --- a/src/pages/Questions/QuestionSwitchWindowTool.tsx +++ b/src/pages/Questions/QuestionSwitchWindowTool.tsx @@ -9,8 +9,7 @@ import {useQuestionsStore} from "@root/questions/store"; export const QuestionSwitchWindowTool = () => { - const {openBranchingPanel, questions} = useQuestionsStore.getState() - console.log("questions ", questions) + const {openBranchingPanel} = useQuestionsStore.getState() return ( diff --git a/src/pages/ResultPage/FirstEntry.tsx b/src/pages/ResultPage/FirstEntry.tsx index 594af76d..e38e30b8 100644 --- a/src/pages/ResultPage/FirstEntry.tsx +++ b/src/pages/ResultPage/FirstEntry.tsx @@ -6,6 +6,7 @@ import { useCurrentQuiz } from "@root/quizes/hooks"; import { Box, Typography, useTheme, useMediaQuery, Button } from "@mui/material"; import image from "../../assets/Rectangle 110.png"; import { enqueueSnackbar } from "notistack"; +import { AnyTypedQuizQuestion } from "@model/questionTypes/shared"; export const FirstEntry = () => { const theme = useTheme(); @@ -20,7 +21,7 @@ export const FirstEntry = () => { return } questions - .filter((question) => question.content.rule.parentId.length !== 0 && question.content.rule.default.length === 0) + .filter((question:AnyTypedQuizQuestion) => question.type !== null && question.content.rule.parentId.length !== 0 && question.content.rule.default.length === 0) .forEach(question => { createFrontResult(quiz.id, question.content.id) }) diff --git a/src/pages/ResultPage/ResultSettings.tsx b/src/pages/ResultPage/ResultSettings.tsx index 8087d731..2732b061 100644 --- a/src/pages/ResultPage/ResultSettings.tsx +++ b/src/pages/ResultPage/ResultSettings.tsx @@ -16,6 +16,7 @@ import { useCurrentQuiz } from "@root/quizes/hooks" export const ResultSettings = () => { const quiz = useCurrentQuiz() + console.log("опросник ", quiz) const [quizExpand, setQuizExpand] = useState(true) const [resultContract, setResultContract] = useState(true) diff --git a/src/stores/questions/actions.ts b/src/stores/questions/actions.ts index 53173737..20f4125e 100644 --- a/src/stores/questions/actions.ts +++ b/src/stores/questions/actions.ts @@ -90,6 +90,7 @@ const updateQuestionOrders = () => { const questions = useQuestionsStore.getState().questions.filter( (question): question is AnyTypedQuizQuestion => question.type !== null && question.type !== "result" ); + console.log(questions) questions.forEach((question, index) => { updateQuestion(question.id, question => {