2023-09-05 08:25:47 +00:00
|
|
|
|
import { Box, Button, IconButton, Typography, useTheme } from "@mui/material";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import AddPlus from "../../assets/icons/questionsPage/addPlus";
|
|
|
|
|
import ArrowLeft from "../../assets/icons/questionsPage/arrowLeft";
|
2023-08-03 07:45:06 +00:00
|
|
|
|
import { quizStore } from "@root/quizes";
|
|
|
|
|
import { useParams } from "react-router-dom";
|
2023-09-05 08:25:47 +00:00
|
|
|
|
import {
|
|
|
|
|
questionStore,
|
|
|
|
|
createQuestion,
|
|
|
|
|
updateQuestionsList,
|
|
|
|
|
} from "@root/questions";
|
2023-08-11 07:25:28 +00:00
|
|
|
|
import { DraggableList } from "./DraggableList";
|
2023-03-15 22:56:53 +00:00
|
|
|
|
|
|
|
|
|
export default function QuestionsPage() {
|
2023-08-03 07:45:06 +00:00
|
|
|
|
const { listQuizes, updateQuizesList } = quizStore();
|
|
|
|
|
const params = Number(useParams().quizId);
|
2023-07-27 17:30:55 +00:00
|
|
|
|
const { listQuestions } = questionStore();
|
2023-08-03 07:45:06 +00:00
|
|
|
|
const handleNext = () => {
|
|
|
|
|
updateQuizesList(params, { step: listQuizes[params].step + 1 });
|
|
|
|
|
};
|
2023-03-15 22:56:53 +00:00
|
|
|
|
|
2023-08-03 07:45:06 +00:00
|
|
|
|
const handleBack = () => {
|
|
|
|
|
let result = listQuizes[params].step - 1;
|
|
|
|
|
updateQuizesList(params, { step: result ? result : 1 });
|
|
|
|
|
};
|
2023-06-27 22:26:23 +00:00
|
|
|
|
|
2023-09-05 08:25:47 +00:00
|
|
|
|
const collapseEverything = () => {
|
|
|
|
|
listQuestions.forEach((item, index) => {
|
|
|
|
|
updateQuestionsList(index, { ...item, expanded: false });
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-03 07:45:06 +00:00
|
|
|
|
const theme = useTheme();
|
2023-04-15 09:10:59 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-06-30 14:39:07 +00:00
|
|
|
|
{/*<Stepper activeStep={activeStep} desc={"Задайте вопросы"} />*/}
|
2023-08-03 07:45:06 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
maxWidth: "796px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
margin: "60px 0 40px 0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography variant={"h5"}>Заголовок квиза</Typography>
|
2023-09-05 08:25:47 +00:00
|
|
|
|
<Button
|
2023-08-03 07:45:06 +00:00
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
lineHeight: "19px",
|
2023-09-05 08:25:47 +00:00
|
|
|
|
padding: 0,
|
|
|
|
|
textDecoration: "underline",
|
2023-08-03 07:45:06 +00:00
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
textDecorationColor: theme.palette.brightPurple.main,
|
|
|
|
|
}}
|
2023-09-05 08:25:47 +00:00
|
|
|
|
onClick={collapseEverything}
|
2023-06-30 19:10:47 +00:00
|
|
|
|
>
|
2023-08-03 07:45:06 +00:00
|
|
|
|
Свернуть всё
|
2023-09-05 08:25:47 +00:00
|
|
|
|
</Button>
|
2023-08-03 07:45:06 +00:00
|
|
|
|
</Box>
|
2023-08-11 07:25:28 +00:00
|
|
|
|
<DraggableList />
|
2023-08-03 07:45:06 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
maxWidth: "796px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-06-28 23:32:43 +00:00
|
|
|
|
<IconButton
|
2023-08-03 07:45:06 +00:00
|
|
|
|
onClick={() => {
|
|
|
|
|
createQuestion(params);
|
|
|
|
|
console.log(listQuestions);
|
|
|
|
|
}}
|
2023-06-28 23:32:43 +00:00
|
|
|
|
>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
<AddPlus />
|
|
|
|
|
</IconButton>
|
|
|
|
|
<Box sx={{ display: "flex", gap: "8px" }}>
|
2023-08-03 07:45:06 +00:00
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
sx={{ padding: "10px 20px", borderRadius: "8px" }}
|
|
|
|
|
>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
<ArrowLeft />
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
padding: "10px 20px",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
background: theme.palette.brightPurple.main,
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
}}
|
2023-07-01 23:33:35 +00:00
|
|
|
|
onClick={handleNext}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
>
|
|
|
|
|
Следующий шаг
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|