frontPanel/src/pages/Questions/QuestionSwitchWindowTool.tsx

58 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-12-25 15:38:40 +00:00
import { Box, useMediaQuery, useTheme } from "@mui/material";
import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
import { useCallback } from "react";
import { BranchingMap } from "./BranchingMap";
2023-11-29 15:45:15 +00:00
import { DraggableList } from "./DraggableList";
import { SwitchBranchingPanel } from "./SwitchBranchingPanel";
2023-11-29 15:45:15 +00:00
interface Props {
openBranchingPage: boolean;
setOpenBranchingPage: (a: boolean) => void;
widthMain: number;
}
2023-12-31 02:53:25 +00:00
export const QuestionSwitchWindowTool = ({
openBranchingPage,
setOpenBranchingPage,
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));
const openBranchingPageHC = useCallback(() => {
if (!openBranchingPage) {
deleteTimeoutedQuestions();
2023-12-25 15:38:40 +00:00
}
setOpenBranchingPage(!openBranchingPage);
}, [openBranchingPage, setOpenBranchingPage]);
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" }}>
{openBranchingPage ? (
<BranchingMap />
) : (
<DraggableList
openBranchingPage={openBranchingPage}
setOpenBranchingPage={openBranchingPageHC}
/>
)}
2023-12-31 02:53:25 +00:00
</Box>
{openBranchingPage && (
2023-12-31 02:53:25 +00:00
<SwitchBranchingPanel
openBranchingPage={openBranchingPage}
setOpenBranchingPage={openBranchingPageHC}
widthMain={widthMain}
2023-12-31 02:53:25 +00:00
/>
)}
2023-12-25 15:38:40 +00:00
</Box>
);
};