diff --git a/src/pages/ViewPublicationPage/Footer.tsx b/src/pages/ViewPublicationPage/Footer.tsx index 2e11952d..5b46c9c1 100644 --- a/src/pages/ViewPublicationPage/Footer.tsx +++ b/src/pages/ViewPublicationPage/Footer.tsx @@ -37,13 +37,16 @@ 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, - [answers.at(-1)?.answer].length + [answer?.answer].length ); for ( @@ -51,13 +54,12 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => { i < longerArray; i++ // Цикл по всем эле­мен­там бОльшего массива ) { - if (rules[0].answers[i] === answers.at(-1)?.answer) { + if (rules[0].answers[i] === answer?.answer) { readyBeNextQuestion = next; // Ес­ли хоть один эле­мент от­ли­ча­ет­ся, мас­си­вы не рав­ны } } }); if (readyBeNextQuestion) { - const nextQuestion = getQuestionByContentId(readyBeNextQuestion); if (nextQuestion) {