2023-12-27 07:25:30 +00:00
|
|
|
import { useEffect, useLayoutEffect } from "react";
|
2023-12-25 15:38:40 +00:00
|
|
|
import { Box, useMediaQuery, useTheme } from "@mui/material";
|
2023-11-29 15:45:15 +00:00
|
|
|
import { DraggableList } from "./DraggableList";
|
2023-12-05 23:34:40 +00:00
|
|
|
import { SwitchBranchingPanel } from "./SwitchBranchingPanel";
|
2023-11-29 15:45:15 +00:00
|
|
|
import { BranchingMap } from "./BranchingMap";
|
2023-12-25 15:38:40 +00:00
|
|
|
import { useQuestionsStore } from "@root/questions/store";
|
2023-12-14 09:40:53 +00:00
|
|
|
import { useUiTools } from "@root/uiTools/store";
|
2023-12-25 15:38:40 +00:00
|
|
|
import { useQuestions } from "@root/questions/hooks";
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
|
|
|
|
2023-12-27 07:25:30 +00:00
|
|
|
import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
|
2023-11-29 15:45:15 +00:00
|
|
|
|
2023-12-27 07:25:30 +00:00
|
|
|
interface Props {
|
|
|
|
openBranchingPage: boolean;
|
2023-12-27 11:48:25 +00:00
|
|
|
setOpenBranchingPage: (a: boolean) => void;
|
2023-12-27 07:25:30 +00:00
|
|
|
}
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
export const QuestionSwitchWindowTool = ({
|
|
|
|
openBranchingPage,
|
|
|
|
setOpenBranchingPage,
|
|
|
|
}: Props) => {
|
2023-12-25 15:38:40 +00:00
|
|
|
const { questions } = useQuestionsStore.getState();
|
|
|
|
const theme = useTheme();
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
|
|
|
const quiz = useCurrentQuiz();
|
|
|
|
|
2023-12-27 07:25:30 +00:00
|
|
|
const openBranchingPageHC = () => {
|
|
|
|
if (!openBranchingPage) {
|
2023-12-27 11:48:25 +00:00
|
|
|
deleteTimeoutedQuestions(questions, quiz);
|
2023-12-25 15:38:40 +00:00
|
|
|
}
|
2023-12-27 11:48:25 +00:00
|
|
|
setOpenBranchingPage(!openBranchingPage);
|
|
|
|
};
|
2023-12-25 15:38:40 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
display: "flex",
|
|
|
|
gap: "20px",
|
|
|
|
flexWrap: "wrap",
|
|
|
|
marginBottom: isMobile ? "20px" : undefined,
|
|
|
|
}}
|
|
|
|
>
|
2023-12-31 02:53:25 +00:00
|
|
|
<Box sx={{ flexBasis: "796px" }}>
|
2024-01-05 07:07:06 +00:00
|
|
|
{openBranchingPage ? (
|
|
|
|
<BranchingMap />
|
|
|
|
) : (
|
|
|
|
<DraggableList
|
|
|
|
openBranchingPage={openBranchingPage}
|
|
|
|
setOpenBranchingPage={openBranchingPageHC}
|
|
|
|
/>
|
|
|
|
)}
|
2023-12-31 02:53:25 +00:00
|
|
|
</Box>
|
2023-12-27 11:48:25 +00:00
|
|
|
{openBranchingPage && (
|
2023-12-31 02:53:25 +00:00
|
|
|
<SwitchBranchingPanel
|
|
|
|
openBranchingPage={openBranchingPage}
|
|
|
|
setOpenBranchingPage={openBranchingPageHC}
|
|
|
|
/>
|
2023-12-27 11:48:25 +00:00
|
|
|
)}
|
2023-12-25 15:38:40 +00:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|