10 баллов не ломают балловый опросник

This commit is contained in:
Nastya 2024-02-12 03:54:12 +03:00
parent ec1657496c
commit 3b704c06b7
2 changed files with 45 additions and 32 deletions

@ -152,41 +152,45 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
</Box>
</Box>
<Box
sx={{
boxShadow: "0 0 15px 0 rgba(0,0,0,.08)",
width: "100%",
flexDirection: "column",
display: "flex",
justifyContent: "center",
alignItems: "center",
p: "20px",
}}
>
{settings.cfg.resultInfo.showResultForm === "before" && (
<Button
onClick={() => setCurrentQuizStep("contactform")}
variant="contained"
sx={{
p: "10px 20px",
width: "auto",
height: "50px",
}}
>
{resultQuestion.content.hint.text || "Узнать подробнее"}
</Button>
)}
{settings.cfg.resultInfo.showResultForm === "after" &&
resultQuestion.content.redirect && (
<Box
sx={{
boxShadow: "0 0 15px 0 rgba(0,0,0,.08)",
width: "100%",
flexDirection: "column",
display: "flex",
justifyContent: "center",
alignItems: "center",
p: settings.cfg.resultInfo.showResultForm === "before" ||
(
settings.cfg.resultInfo.showResultForm === "after" &&
resultQuestion.content.redirect
) ? "20px" : "0",
}}
>
{settings.cfg.resultInfo.showResultForm === "before" && (
<Button
href={resultQuestion.content.redirect}
onClick={() => setCurrentQuizStep("contactform")}
variant="contained"
sx={{ p: "10px 20px", width: "auto", height: "50px" }}
sx={{
p: "10px 20px",
width: "auto",
height: "50px",
}}
>
{resultQuestion.content.hint.text || "Перейти на сайт"}
{resultQuestion.content.hint.text || "Узнать подробнее"}
</Button>
)}
</Box>
{settings.cfg.resultInfo.showResultForm === "after" &&
resultQuestion.content.redirect && (
<Button
href={resultQuestion.content.redirect}
variant="contained"
sx={{ p: "10px 20px", width: "auto", height: "50px" }}
>
{resultQuestion.content.hint.text || "Перейти на сайт"}
</Button>
)}
</Box>
</Box>
</Box>
);

@ -97,36 +97,45 @@ export function useQuestionFlowControl() {
const getNextQuestion = () => {
let next
console.log(11111111111)
//Искать можно двумя логиками. Основной и балловой
if (Boolean(settings.cfg.score)) {
//Балловая
console.log(222222222)
//Ищем линейно
if (linearQuestionIndex !== null) {
console.log(33333333333)
next = questions[linearQuestionIndex + 1]
if (next.type === "result") next = findResultPointsLogic()
console.log(4444444)
console.log("перед ифом", next)
if (next?.type === "result" || next == undefined) next = findResultPointsLogic()
console.log(5555555555)
}
} else {
console.log(6666666)
//Основная
if (linearQuestionIndex !== null) {
console.log(777777777)
//Ищем линейно
next = questions[linearQuestionIndex + 1] ?? questions.find(question =>
question.type === "result" && question.content.rule.parentId === "line"
)
} else {
console.log(88888888888888)
//Ищем ветвлением
next = questions.find(q => q.id === calculateNextQuestionId || q.content.id === calculateNextQuestionId);
}
}
if (!next) throw new Error("Не найден следующий вопрос")
console.log("next", next)
if (!next) throw new Error("Не найден следующий вопрос")
return next
}
const nextQuestion = getNextQuestion()