fix: previous button bug
This commit is contained in:
parent
ac31202af6
commit
5c5ef3fac2
@ -86,8 +86,12 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => {
|
|||||||
} else {
|
} else {
|
||||||
enqueueSnackbar("не могу получить предыдущий вопрос");
|
enqueueSnackbar("не могу получить предыдущий вопрос");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
enqueueSnackbar("вы находитесь на первом вопросе");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const followNextStep = () => {
|
||||||
const nextQuestionId = getNextQuestionId();
|
const nextQuestionId = getNextQuestionId();
|
||||||
|
|
||||||
if (nextQuestionId) {
|
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 (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user