From 3b704c06b7f15fc55697fd407c06e1358e059b92 Mon Sep 17 00:00:00 2001 From: Nastya Date: Mon, 12 Feb 2024 03:54:12 +0300 Subject: [PATCH] =?UTF-8?q?10=20=D0=B1=D0=B0=D0=BB=D0=BB=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BB=D0=BE=D0=BC=D0=B0=D1=8E=D1=82=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=BB=D0=BB=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D0=BD=D0=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ViewPublicationPage/ResultForm.tsx | 64 +++++++++++--------- src/utils/hooks/useQuestionFlowControl.ts | 13 +++- 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/pages/ViewPublicationPage/ResultForm.tsx b/src/pages/ViewPublicationPage/ResultForm.tsx index c601bd9..1f4b153 100644 --- a/src/pages/ViewPublicationPage/ResultForm.tsx +++ b/src/pages/ViewPublicationPage/ResultForm.tsx @@ -152,41 +152,45 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => { - - {settings.cfg.resultInfo.showResultForm === "before" && ( - - )} - {settings.cfg.resultInfo.showResultForm === "after" && - resultQuestion.content.redirect && ( + + {settings.cfg.resultInfo.showResultForm === "before" && ( )} - + {settings.cfg.resultInfo.showResultForm === "after" && + resultQuestion.content.redirect && ( + + )} + ); diff --git a/src/utils/hooks/useQuestionFlowControl.ts b/src/utils/hooks/useQuestionFlowControl.ts index c896b7f..0f80843 100644 --- a/src/utils/hooks/useQuestionFlowControl.ts +++ b/src/utils/hooks/useQuestionFlowControl.ts @@ -97,36 +97,45 @@ export function useQuestionFlowControl() { const getNextQuestion = () => { let next + console.log(11111111111) //Искать можно двумя логиками. Основной и балловой if (Boolean(settings.cfg.score)) { //Балловая + console.log(222222222) //Ищем линейно if (linearQuestionIndex !== null) { + console.log(33333333333) next = questions[linearQuestionIndex + 1] - if (next.type === "result") next = findResultPointsLogic() + console.log(4444444) + console.log("перед ифом", next) + if (next?.type === "result" || next == undefined) next = findResultPointsLogic() + console.log(5555555555) } } else { + console.log(6666666) //Основная if (linearQuestionIndex !== null) { + console.log(777777777) //Ищем линейно next = questions[linearQuestionIndex + 1] ?? questions.find(question => question.type === "result" && question.content.rule.parentId === "line" ) } else { + console.log(88888888888888) //Ищем ветвлением next = questions.find(q => q.id === calculateNextQuestionId || q.content.id === calculateNextQuestionId); } } - if (!next) throw new Error("Не найден следующий вопрос") console.log("next", next) + if (!next) throw new Error("Не найден следующий вопрос") return next } const nextQuestion = getNextQuestion()