From 5c5ef3fac2b05fa97fa45f44af80c5e85b176cf8 Mon Sep 17 00:00:00 2001 From: IlyaDoronin Date: Tue, 5 Dec 2023 13:33:01 +0300 Subject: [PATCH] fix: previous button bug --- src/pages/ViewPublicationPage/Footer.tsx | 50 ++---------------------- 1 file changed, 4 insertions(+), 46 deletions(-) diff --git a/src/pages/ViewPublicationPage/Footer.tsx b/src/pages/ViewPublicationPage/Footer.tsx index 4a7c1e70..90ce11c7 100644 --- a/src/pages/ViewPublicationPage/Footer.tsx +++ b/src/pages/ViewPublicationPage/Footer.tsx @@ -86,8 +86,12 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => { } else { enqueueSnackbar("не могу получить предыдущий вопрос"); } + } else { + enqueueSnackbar("вы находитесь на первом вопросе"); } + }; + const followNextStep = () => { const nextQuestionId = getNextQuestionId(); if (nextQuestionId) { @@ -111,52 +115,6 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => { } }; - const followNextStep = () => { - if (answers.length) { - const answer = answers.find( - ({ questionId }) => questionId === question.content.id - ); - - let readyBeNextQuestion = ""; - - question.content.rule.main.forEach(({ next, rules }) => { - let longerArray = Math.max( - rules[0].answers.length, - [answer?.answer].length - ); - - for ( - var i = 0; - i < longerArray; - i++ // Цикл по всем эле­мен­там бОльшего массива - ) { - if (rules[0].answers[i] === answer?.answer) { - readyBeNextQuestion = next; // Ес­ли хоть один эле­мент от­ли­ча­ет­ся, мас­си­вы не рав­ны - } - } - }); - if (readyBeNextQuestion) { - const nextQuestion = getQuestionByContentId(readyBeNextQuestion); - - if (nextQuestion?.type) { - setCurrentQuestion(nextQuestion); - return; - } else { - enqueueSnackbar("не могу получить последующий вопрос"); - } - } else { - const nextQuestion = getQuestionByContentId( - question.content.rule.default - ); - if (nextQuestion?.type) { - setCurrentQuestion(nextQuestion); - } else { - enqueueSnackbar("не могу получить последующий вопрос (дефолтный)"); - } - } - } - }; - return (