для линейного опросника сразу ищется линейный резулт

This commit is contained in:
Nastya 2024-01-05 15:00:36 +03:00
parent d9aaf8524a
commit 6b5bf705c6
2 changed files with 25 additions and 9 deletions

@ -109,6 +109,7 @@ export const Footer = ({
}, [question, answers]);
const showResult = (nextQuestion) => {
console.log("Следующий результат будет вот такой" , nextQuestion)
if (nextQuestion && quiz?.config.resultInfo.when === "email") {
setShowContactForm(true);
return;
@ -241,6 +242,7 @@ export const Footer = ({
};
const followNextStep = () => {
console.log(" Я понимаю что нахожусь в линейном опроснике" + linear)
if (linear) {
setStepNumber((q) => q + 1);
const questionIndex = questions.findIndex(({ id }) => id === question.id);

@ -25,15 +25,28 @@ export const ResultForm = ({
const quiz = useCurrentQuiz();
const mode = modes;
const { questions } = useQuestionsStore();
const resultQuestion = (questions.find(
(question) =>
question.type === "result" &&
question.content.rule.parentId === currentQuestion.content.id,
) ||
questions.find(
(question) =>
question.type === "result" && question.content.rule.parentId === "line",
)) as AnyTypedQuizQuestion;
const searchResult = () => {
if (Boolean(quiz?.config.haveRoot)) {
//ищём для ветвления
return (questions.find(
(question) =>
question.type === "result" &&
question.content.rule.parentId === currentQuestion.content.id,
) ||
questions.find(
(question) =>
question.type === "result" && question.content.rule.parentId === "line",
)) as AnyTypedQuizQuestion;
} else {
return questions.find(
(question) =>
question.type === "result" && question.content.rule.parentId === "line",
) as AnyTypedQuizQuestion;
}
}
const resultQuestion = searchResult()
const followNextForm = () => {
setShowResultForm(false);
@ -41,6 +54,7 @@ export const ResultForm = ({
};
if (resultQuestion === undefined) return <></>;
console.log("Я форма показа резултата и он такой ", resultQuestion)
return (
<Box
sx={{