2023-12-01 14:33:55 +00:00
|
|
|
|
import { useEffect } from "react";
|
2023-09-20 09:07:33 +00:00
|
|
|
|
import {
|
2023-12-01 14:33:55 +00:00
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
IconButton,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
2023-09-20 09:07:33 +00:00
|
|
|
|
} from "@mui/material";
|
2023-12-01 14:33:55 +00:00
|
|
|
|
import {
|
|
|
|
|
collapseAllQuestions,
|
|
|
|
|
createUntypedQuestion,
|
|
|
|
|
} from "@root/questions/actions";
|
|
|
|
|
import {
|
|
|
|
|
decrementCurrentStep,
|
|
|
|
|
incrementCurrentStep,
|
|
|
|
|
} from "@root/quizes/actions";
|
2023-11-14 20:15:52 +00:00
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
|
|
|
|
import QuizPreview from "@ui_kit/QuizPreview/QuizPreview";
|
|
|
|
|
import { createPortal } from "react-dom";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import AddPlus from "../../assets/icons/questionsPage/addPlus";
|
|
|
|
|
import ArrowLeft from "../../assets/icons/questionsPage/arrowLeft";
|
2023-08-11 07:25:28 +00:00
|
|
|
|
import { DraggableList } from "./DraggableList";
|
2023-12-01 14:33:55 +00:00
|
|
|
|
import { setDefaultState } from "@root/questions/actions";
|
2023-03-15 22:56:53 +00:00
|
|
|
|
|
|
|
|
|
export default function QuestionsPage() {
|
2023-12-01 14:33:55 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
|
|
|
|
const quiz = useCurrentQuiz();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const setDefault = ({ code }: KeyboardEvent) => {
|
|
|
|
|
if (code === "Backslash") {
|
|
|
|
|
setDefaultState(Number(quiz?.id));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
document.addEventListener("keydown", setDefault);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
document.removeEventListener("keydown", setDefault);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
2023-06-27 22:26:23 +00:00
|
|
|
|
|
2023-12-01 14:33:55 +00:00
|
|
|
|
if (!quiz) return null;
|
2023-09-15 12:37:12 +00:00
|
|
|
|
|
2023-12-01 14:33:55 +00:00
|
|
|
|
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={collapseAllQuestions}
|
|
|
|
|
>
|
|
|
|
|
Свернуть всё
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
<DraggableList />
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
maxWidth: "796px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<IconButton
|
|
|
|
|
onClick={() => {
|
|
|
|
|
createUntypedQuestion(quiz.backendId);
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
position: "fixed",
|
|
|
|
|
left: isMobile ? "20px" : "250px",
|
|
|
|
|
bottom: "20px",
|
|
|
|
|
}}
|
|
|
|
|
data-cy="create-question"
|
|
|
|
|
>
|
|
|
|
|
<AddPlus />
|
|
|
|
|
</IconButton>
|
|
|
|
|
<Box sx={{ display: "flex", gap: "8px", marginLeft: "auto" }}>
|
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
sx={{ padding: "10px 20px", borderRadius: "8px", height: "44px" }}
|
|
|
|
|
data-cy="back-button"
|
|
|
|
|
onClick={decrementCurrentStep}
|
|
|
|
|
>
|
|
|
|
|
<ArrowLeft />
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
height: "44px",
|
|
|
|
|
padding: "10px 20px",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
background: theme.palette.brightPurple.main,
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
}}
|
|
|
|
|
onClick={incrementCurrentStep}
|
|
|
|
|
>
|
|
|
|
|
Следующий шаг
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
{createPortal(<QuizPreview />, document.body)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}
|