diff --git a/src/pages/ViewPublicationPage/index.tsx b/src/pages/ViewPublicationPage/index.tsx index e8a97e1d..6642dce5 100644 --- a/src/pages/ViewPublicationPage/index.tsx +++ b/src/pages/ViewPublicationPage/index.tsx @@ -56,7 +56,7 @@ useEffect(() => { if (visualStartPage === undefined) return <> return ( - {!visualStartPage ? ( + {visualStartPage ? ( ) : ( diff --git a/src/pages/ViewPublicationPage/questions/Number.tsx b/src/pages/ViewPublicationPage/questions/Number.tsx index 5b49ed41..6634e4b1 100644 --- a/src/pages/ViewPublicationPage/questions/Number.tsx +++ b/src/pages/ViewPublicationPage/questions/Number.tsx @@ -8,7 +8,6 @@ import { CustomSlider } from "@ui_kit/CustomSlider"; import { useQuizViewStore, updateAnswer } from "@root/quizView"; import type { QuizQuestionNumber } from "../../../model/questionTypes/number"; -import {CustomSlider} from "@ui_kit/CustomSlider"; type NumberProps = { currentQuestion: QuizQuestionNumber; @@ -39,27 +38,21 @@ export const Number = ({ currentQuestion }: NumberProps) => { }, 1000 ); - const { answer } = - answers.find( - ({ questionId }) => questionId === currentQuestion.content.id - ) ?? {}; + const answer = answers.find( + ({ questionId }) => questionId === currentQuestion.content.id + )?.answer as string; const min = window.Number(currentQuestion.content.range.split("—")[0]); const max = window.Number(currentQuestion.content.range.split("—")[1]); + const sliderValue = answer || currentQuestion.content.start + "—" + max; useEffect(() => { if (answer) { setMinRange(answer.split("—")[0]); setMaxRange(answer.split("—")[1]); } - if (!answer) { - updateAnswer( - currentQuestion.content.id, - currentQuestion.content.chooseRange - ? `${currentQuestion.content.start}—${max}` - : String(currentQuestion.content.start) - ); + if (!answer) { setMinRange(String(currentQuestion.content.start)); setMaxRange(String(max)); } @@ -80,10 +73,10 @@ export const Number = ({ currentQuestion }: NumberProps) => { 1 - ? answer?.split("—").map((item) => window.Number(item)) + ? sliderValue.split("—").length || 0 > 1 + ? sliderValue.split("—").map((item) => window.Number(item)) : [min, min + 1] - : window.Number(answer || 1) + : window.Number(sliderValue.split("—")[0]) } min={min} max={max}