feat: question analysis in view
This commit is contained in:
parent
64601e74de
commit
8e6852f38c
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user