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

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