2023-12-15 12:12:36 +00:00
|
|
|
|
import { Box, Typography, Button } from "@mui/material";
|
|
|
|
|
|
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
2023-12-16 09:36:35 +00:00
|
|
|
|
import { useQuestionsStore } from "@root/questions/store";
|
|
|
|
|
|
|
|
|
|
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
|
|
|
|
type ResultFormProps = {
|
2023-12-16 09:36:35 +00:00
|
|
|
|
currentQuestion: AnyTypedQuizQuestion;
|
2023-12-15 12:12:36 +00:00
|
|
|
|
showContactForm: boolean;
|
|
|
|
|
setShowContactForm: (show: boolean) => void;
|
|
|
|
|
setShowResultForm: (show: boolean) => void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const ResultForm = ({
|
2023-12-16 09:36:35 +00:00
|
|
|
|
currentQuestion,
|
2023-12-15 12:12:36 +00:00
|
|
|
|
showContactForm,
|
|
|
|
|
setShowContactForm,
|
|
|
|
|
setShowResultForm,
|
|
|
|
|
}: ResultFormProps) => {
|
|
|
|
|
const quiz = useCurrentQuiz();
|
2023-12-16 09:36:35 +00:00
|
|
|
|
const { questions } = useQuestionsStore();
|
|
|
|
|
const resultQuestion = questions.find(
|
|
|
|
|
(question) =>
|
|
|
|
|
question.type === "result" &&
|
|
|
|
|
question.content.rule.parentId === currentQuestion.content.id
|
|
|
|
|
);
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
|
|
|
|
const followNextForm = () => {
|
|
|
|
|
setShowResultForm(false);
|
|
|
|
|
setShowContactForm(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography>Форма результатов</Typography>
|
2023-12-16 09:36:35 +00:00
|
|
|
|
<Typography>{JSON.stringify(resultQuestion)}</Typography>
|
2023-12-15 12:12:36 +00:00
|
|
|
|
{!showContactForm && quiz?.config.resultInfo.when !== "after" && (
|
|
|
|
|
<Button variant="contained" onClick={followNextForm}>
|
|
|
|
|
Показать форму контактов
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|