страница результатов не отображается если не заполнена
This commit is contained in:
parent
1ca17853e9
commit
74d22956a8
@ -11,6 +11,7 @@ import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
||||
import { useState } from "react";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
|
||||
import { checkEmptyData } from "../ResultPage/cards/ResultCard";
|
||||
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
|
||||
@ -44,11 +45,23 @@ export const ContactForm = ({
|
||||
setShowResultForm(true);
|
||||
};
|
||||
|
||||
const resultQuestion = questions.find(
|
||||
(question) =>
|
||||
|
||||
const resultQuestion = questions.find((question) => {
|
||||
if (quiz?.config.haveRoot) { //ветвимся
|
||||
return (
|
||||
question.type === "result" &&
|
||||
question.content.rule.parentId === currentQuestion.content.id
|
||||
)
|
||||
} else {// не ветвимся
|
||||
return (
|
||||
question.type === "result" &&
|
||||
question.content.rule.parentId === "line"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@ -117,7 +130,10 @@ export const ContactForm = ({
|
||||
<Button
|
||||
disabled={!ready}
|
||||
variant="contained" onClick={() => {
|
||||
if (quiz?.config.resultInfo.when === "after") followNextForm()
|
||||
if (quiz?.config.resultInfo.when === "after" && !checkEmptyData({ resultData: resultQuestion })) {
|
||||
setShowContactForm(false)
|
||||
setShowResultForm(true)
|
||||
}
|
||||
}}>
|
||||
Получить результаты
|
||||
</Button>
|
||||
|
||||
@ -9,6 +9,7 @@ import type { AnyTypedQuizQuestion, QuizQuestionBase } from "../../model/questio
|
||||
import { getQuestionByContentId } from "@root/questions/actions";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { NameplateLogoFQ } from "@icons/NameplateLogoFQ";
|
||||
import { checkEmptyData } from "../ResultPage/cards/ResultCard";
|
||||
|
||||
type FooterProps = {
|
||||
setCurrentQuestion: (step: AnyTypedQuizQuestion) => void;
|
||||
@ -80,11 +81,35 @@ export const Footer = ({ setCurrentQuestion, question, setShowContactForm, setSh
|
||||
|
||||
const showResult = (nextQuestion) => {
|
||||
|
||||
if (nextQuestion && quiz?.config.resultInfo.when === "before") {
|
||||
setShowResultForm(true);
|
||||
} else {
|
||||
|
||||
if (nextQuestion && quiz?.config.resultInfo.when === "email") {
|
||||
setShowContactForm(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const isEmpty = checkEmptyData({ resultData: nextQuestion })
|
||||
console.log("пустой результат? ", isEmpty)
|
||||
if (nextQuestion) {
|
||||
if (nextQuestion && quiz?.config.resultInfo.when === "before") {
|
||||
if (isEmpty) {
|
||||
setShowContactForm(true); //до+пустая = кидать на ФК
|
||||
console.log("до+пустая = кидать на ФК")
|
||||
} else {
|
||||
setShowResultForm(true); //до+заполнена = показать
|
||||
console.log("до+заполнена = показать")
|
||||
}
|
||||
}
|
||||
if (nextQuestion && quiz?.config.resultInfo.when === "after") {
|
||||
if (isEmpty) {
|
||||
setShowContactForm(true); //после+пустая
|
||||
console.log("после+пустая")
|
||||
} else {
|
||||
setShowContactForm(true); //после+заполнена = показать ФК
|
||||
console.log("после+заполнена = показать")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const getNextQuestionId = () => {
|
||||
@ -161,10 +186,10 @@ export const Footer = ({ setCurrentQuestion, question, setShowContactForm, setSh
|
||||
} else {
|
||||
showResult(nextQuestion);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const nextQuestionId = getNextQuestionId();
|
||||
|
||||
if (nextQuestionId) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user