2023-10-10 13:33:21 +00:00
|
|
|
|
import { Box, Button, IconButton, Typography, useTheme } from "@mui/material";
|
|
|
|
|
import { useParams } from "react-router-dom";
|
|
|
|
|
|
|
|
|
|
import { FormDraggableList } from "./FormDraggableList";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
questionStore,
|
|
|
|
|
createQuestion,
|
|
|
|
|
updateQuestionsList,
|
|
|
|
|
} from "@root/questions";
|
|
|
|
|
import { quizStore } from "@root/quizes";
|
|
|
|
|
|
|
|
|
|
import AddPlus from "../../../assets/icons/questionsPage/addPlus";
|
|
|
|
|
import ArrowLeft from "../../../assets/icons/questionsPage/arrowLeft";
|
2023-10-12 08:15:19 +00:00
|
|
|
|
import AddAnswer from "../../../assets/icons/questionsPage/addAnswer";
|
2023-10-10 13:33:21 +00:00
|
|
|
|
|
2023-10-12 08:15:19 +00:00
|
|
|
|
import type {
|
|
|
|
|
AnyQuizQuestion,
|
|
|
|
|
QuizQuestionBase,
|
|
|
|
|
} from "../../../model/questionTypes/shared";
|
2023-10-10 13:33:21 +00:00
|
|
|
|
|
|
|
|
|
export default function FormQuestionsPage() {
|
|
|
|
|
const { listQuizes, updateQuizesList } = quizStore();
|
|
|
|
|
const quizId = Number(useParams().quizId);
|
|
|
|
|
const { listQuestions } = questionStore();
|
|
|
|
|
const handleNext = () => {
|
|
|
|
|
updateQuizesList(quizId, { step: listQuizes[quizId].step + 1 });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const collapseEverything = () => {
|
|
|
|
|
listQuestions[quizId].forEach((item, index) => {
|
|
|
|
|
updateQuestionsList<AnyQuizQuestion>(quizId, index, {
|
|
|
|
|
...item,
|
|
|
|
|
expanded: false,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
maxWidth: "796px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
margin: "60px 0 40px 0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography variant={"h5"}>Заголовок анкеты</Typography>
|
|
|
|
|
<Button
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
lineHeight: "19px",
|
|
|
|
|
padding: 0,
|
|
|
|
|
textDecoration: "underline",
|
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
textDecorationColor: theme.palette.brightPurple.main,
|
|
|
|
|
}}
|
|
|
|
|
onClick={collapseEverything}
|
|
|
|
|
>
|
|
|
|
|
Свернуть всё
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
2023-10-12 08:15:19 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
maxWidth: "796px",
|
|
|
|
|
boxShadow: "0px 10px 30px #e7e7e7",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
marginBottom: "40px",
|
2023-10-12 15:51:39 +00:00
|
|
|
|
borderTop: "1px solid transparent",
|
|
|
|
|
borderBottom: "1px solid transparent",
|
|
|
|
|
background: "#FFFFFF",
|
2023-10-12 08:15:19 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<FormDraggableList />
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "15px",
|
|
|
|
|
padding: "4px",
|
|
|
|
|
margin: "15px",
|
|
|
|
|
border: "1px solid transparent",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
border: "1px solid #9A9AAF",
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
createQuestion(quizId);
|
|
|
|
|
updateQuestionsList<QuizQuestionBase>(quizId, 0, {
|
|
|
|
|
expanded: true,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<AddAnswer color="#EEE4FC" />
|
|
|
|
|
<Typography sx={{ color: "#9A9AAF" }}>
|
|
|
|
|
Добавить еще один вопрос
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2023-10-10 13:33:21 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
2023-10-11 14:32:26 +00:00
|
|
|
|
justifyContent: "flex-end",
|
|
|
|
|
gap: "8px",
|
2023-10-10 13:33:21 +00:00
|
|
|
|
maxWidth: "796px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-10-11 14:32:26 +00:00
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
sx={{ padding: "10px 20px", borderRadius: "8px", height: "44px" }}
|
|
|
|
|
>
|
|
|
|
|
<ArrowLeft />
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
height: "44px",
|
|
|
|
|
padding: "10px 20px",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
background: theme.palette.brightPurple.main,
|
|
|
|
|
fontSize: "18px",
|
2023-10-10 13:33:21 +00:00
|
|
|
|
}}
|
2023-10-11 14:32:26 +00:00
|
|
|
|
onClick={handleNext}
|
2023-10-10 13:33:21 +00:00
|
|
|
|
>
|
2023-10-11 14:32:26 +00:00
|
|
|
|
Следующий шаг
|
|
|
|
|
</Button>
|
2023-10-10 13:33:21 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|