2024-05-17 09:13:02 +00:00
|
|
|
import { Box, Skeleton, useMediaQuery, useTheme } from "@mui/material";
|
2024-02-25 11:12:41 +00:00
|
|
|
import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
|
2024-05-17 09:13:02 +00:00
|
|
|
import { lazy, Suspense, useCallback } from "react";
|
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
|
|
|
|
2024-05-17 09:13:02 +00:00
|
|
|
const BranchingMap = lazy(() =>
|
|
|
|
import("./BranchingMap").then((module) => ({ default: module.BranchingMap })),
|
|
|
|
);
|
2023-12-27 07:25:30 +00:00
|
|
|
interface Props {
|
|
|
|
openBranchingPage: boolean;
|
2023-12-27 11:48:25 +00:00
|
|
|
setOpenBranchingPage: (a: boolean) => void;
|
2024-01-14 19:34:56 +00:00
|
|
|
widthMain: number;
|
2023-12-27 07:25:30 +00:00
|
|
|
}
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
export const QuestionSwitchWindowTool = ({
|
|
|
|
openBranchingPage,
|
|
|
|
setOpenBranchingPage,
|
2024-01-14 19:34:56 +00:00
|
|
|
widthMain,
|
2023-12-31 02:53:25 +00:00
|
|
|
}: Props) => {
|
2023-12-25 15:38:40 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
2024-05-14 15:23:04 +00:00
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
2023-12-25 15:38:40 +00:00
|
|
|
|
2024-02-25 11:12:41 +00:00
|
|
|
const openBranchingPageHC = useCallback(() => {
|
2023-12-27 07:25:30 +00:00
|
|
|
if (!openBranchingPage) {
|
2024-02-25 11:12:41 +00:00
|
|
|
deleteTimeoutedQuestions();
|
2023-12-25 15:38:40 +00:00
|
|
|
}
|
2023-12-27 11:48:25 +00:00
|
|
|
setOpenBranchingPage(!openBranchingPage);
|
2024-02-25 11:12:41 +00:00
|
|
|
}, [openBranchingPage, setOpenBranchingPage]);
|
2023-12-25 15:38:40 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
display: "flex",
|
2024-05-17 09:13:02 +00:00
|
|
|
flexWrap: "wrap",
|
2024-05-16 18:16:08 +00:00
|
|
|
marginBottom: isMobile ? "25px" : "30px",
|
2023-12-25 15:38:40 +00:00
|
|
|
}}
|
|
|
|
>
|
2024-05-14 15:23:04 +00:00
|
|
|
<Box sx={{ width: isTablet ? "100%" : "796px" }}>
|
2024-01-05 07:07:06 +00:00
|
|
|
{openBranchingPage ? (
|
2024-05-17 09:13:02 +00:00
|
|
|
<Suspense
|
|
|
|
fallback={
|
|
|
|
<Skeleton
|
|
|
|
sx={{
|
|
|
|
maxWidth: "796px",
|
|
|
|
width: "100%",
|
|
|
|
height: isMobile ? "357px" : "521px",
|
|
|
|
transform: "none",
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<BranchingMap />
|
|
|
|
</Suspense>
|
2024-01-05 07:07:06 +00:00
|
|
|
) : (
|
|
|
|
<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}
|
2024-01-14 19:34:56 +00:00
|
|
|
widthMain={widthMain}
|
2023-12-31 02:53:25 +00:00
|
|
|
/>
|
2023-12-27 11:48:25 +00:00
|
|
|
)}
|
2023-12-25 15:38:40 +00:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|