2023-05-03 23:25:35 +00:00
|
|
|
|
import IconPlus from "@icons/IconPlus";
|
2023-11-20 17:22:13 +00:00
|
|
|
|
import Info from "@icons/Info";
|
|
|
|
|
import Plus from "@icons/Plus";
|
2023-05-07 14:01:03 +00:00
|
|
|
|
import ArrowLeft from "@icons/questionsPage/arrowLeft";
|
2023-12-09 22:03:53 +00:00
|
|
|
|
import { Box, Button, Typography, Paper, Modal, TextField } from "@mui/material";
|
2023-11-20 17:22:13 +00:00
|
|
|
|
import { incrementCurrentStep } from "@root/quizes/actions";
|
|
|
|
|
import CustomWrapper from "@ui_kit/CustomWrapper";
|
|
|
|
|
import { DescriptionForm } from "./DescriptionForm/DescriptionForm";
|
|
|
|
|
import { ResultListForm } from "./ResultListForm";
|
|
|
|
|
import { SettingForm } from "./SettingForm";
|
2023-12-10 17:15:55 +00:00
|
|
|
|
import { useEffect, useRef, useState } from "react";
|
2023-12-07 22:56:31 +00:00
|
|
|
|
import { WhenCard } from "./cards/WhenCard";
|
2023-12-10 17:15:55 +00:00
|
|
|
|
import { ResultCard, checkEmptyData } from "./cards/ResultCard";
|
2023-12-07 22:56:31 +00:00
|
|
|
|
import { EmailSettingsCard } from "./cards/EmailSettingsCard";
|
2023-12-19 23:08:33 +00:00
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
2023-12-09 21:04:26 +00:00
|
|
|
|
import { useQuestionsStore } from "@root/questions/store";
|
2023-12-11 10:08:54 +00:00
|
|
|
|
import { createFrontResult, deleteQuestion } from "@root/questions/actions";
|
2023-12-09 21:04:26 +00:00
|
|
|
|
import { QuizQuestionResult } from "@model/questionTypes/result";
|
2023-12-07 22:56:31 +00:00
|
|
|
|
|
|
|
|
|
export const ResultSettings = () => {
|
2023-12-19 23:08:33 +00:00
|
|
|
|
const { questions } = useQuestionsStore();
|
|
|
|
|
const quiz = useCurrentQuiz();
|
|
|
|
|
const results = useQuestionsStore().questions.filter((q): q is QuizQuestionResult => q.type === "result");
|
|
|
|
|
const [quizExpand, setQuizExpand] = useState(true);
|
|
|
|
|
const [resultContract, setResultContract] = useState(true);
|
2023-12-10 17:15:55 +00:00
|
|
|
|
const isReadyToLeaveRef = useRef(true);
|
2023-12-09 21:04:26 +00:00
|
|
|
|
|
2023-12-19 23:08:33 +00:00
|
|
|
|
useEffect(
|
|
|
|
|
function calcIsReadyToLeave() {
|
|
|
|
|
let isReadyToLeave = true;
|
|
|
|
|
results.forEach((result) => {
|
|
|
|
|
if (checkEmptyData({ resultData: result })) {
|
|
|
|
|
isReadyToLeave = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
isReadyToLeaveRef.current = isReadyToLeave;
|
|
|
|
|
},
|
|
|
|
|
[results]
|
|
|
|
|
);
|
2023-12-09 22:03:53 +00:00
|
|
|
|
|
2023-12-11 10:08:54 +00:00
|
|
|
|
useEffect(() => {
|
2023-12-19 23:08:33 +00:00
|
|
|
|
return () => {
|
|
|
|
|
if (isReadyToLeaveRef.current === false) alert("Пожалуйста, проверьте, что вы заполнили все результаты");
|
|
|
|
|
};
|
2023-12-10 17:15:55 +00:00
|
|
|
|
}, []);
|
2023-12-11 10:08:54 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
return (
|
2023-10-16 14:23:44 +00:00
|
|
|
|
<Box sx={{ maxWidth: "796px" }}>
|
2023-12-19 23:08:33 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
margin: "60px 0 40px 0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography variant="h5">Настройки результатов</Typography>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
<Info />
|
|
|
|
|
<Button
|
|
|
|
|
disableRipple
|
|
|
|
|
sx={{
|
|
|
|
|
ml: "auto",
|
|
|
|
|
width: "73px",
|
|
|
|
|
height: "19px",
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
textDecoration: "underline",
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
background: "none",
|
|
|
|
|
textDecoration: "underline",
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
variant="text"
|
2023-12-07 22:56:31 +00:00
|
|
|
|
onClick={() => setQuizExpand(!quizExpand)}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
>
|
|
|
|
|
Свернуть
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
2023-12-07 22:56:31 +00:00
|
|
|
|
|
|
|
|
|
<WhenCard quizExpand={quizExpand} />
|
|
|
|
|
{quiz.config.resultInfo.when === "email" && <EmailSettingsCard quizExpand={quizExpand} />}
|
|
|
|
|
|
2023-12-19 23:08:33 +00:00
|
|
|
|
<Box sx={{ display: "flex", alignItems: "center", mb: "15px", mt: "15px" }}>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
<Typography variant="p1" sx={{ color: "#4D4D4D", fontSize: "14px" }}>
|
|
|
|
|
Создайте результат
|
|
|
|
|
</Typography>
|
|
|
|
|
<Button
|
|
|
|
|
disableRipple
|
|
|
|
|
sx={{
|
|
|
|
|
ml: "auto",
|
|
|
|
|
height: "19px",
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
textDecoration: "underline",
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
|
|
|
|
|
"&:hover": {
|
|
|
|
|
background: "none",
|
|
|
|
|
textDecoration: "underline",
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
variant="text"
|
2023-12-07 22:56:31 +00:00
|
|
|
|
onClick={() => setResultContract(!resultContract)}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
>
|
|
|
|
|
Развернуть все
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
|
2023-12-19 23:08:33 +00:00
|
|
|
|
{results.map((resultQuestion) => (
|
|
|
|
|
<ResultCard resultContract={resultContract} resultData={resultQuestion} key={resultQuestion.id} />
|
|
|
|
|
))}
|
2023-12-09 22:03:53 +00:00
|
|
|
|
<Modal
|
|
|
|
|
open={false}
|
|
|
|
|
// onClose={handleClose}
|
|
|
|
|
aria-labelledby="modal-modal-title"
|
|
|
|
|
aria-describedby="modal-modal-description"
|
|
|
|
|
>
|
|
|
|
|
<></>
|
|
|
|
|
</Modal>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
);
|
2023-04-23 08:39:34 +00:00
|
|
|
|
};
|