2023-12-13 23:08:31 +00:00
|
|
|
|
|
|
|
|
|
|
2023-12-05 23:34:40 +00:00
|
|
|
|
import {Box, Typography, Switch, useTheme, Button, useMediaQuery} from "@mui/material";
|
|
|
|
|
|
|
|
|
|
import { QuestionsList } from "./QuestionsList";
|
2023-12-14 09:40:53 +00:00
|
|
|
|
import { updateOpenBranchingPanel } from "@root/uiTools/actions";
|
2023-12-05 23:34:40 +00:00
|
|
|
|
import {useQuestionsStore} from "@root/questions/store";
|
|
|
|
|
import {useRef} from "react";
|
2023-12-14 09:40:53 +00:00
|
|
|
|
import { useUiTools } from "@root/uiTools/store";
|
2023-12-05 23:34:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const SwitchBranchingPanel = () => {
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
2023-12-14 09:40:53 +00:00
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
|
|
|
|
|
|
|
|
|
const {openBranchingPanel} = useUiTools()
|
2023-12-05 23:34:40 +00:00
|
|
|
|
const ref = useRef()
|
2023-12-14 09:40:53 +00:00
|
|
|
|
|
|
|
|
|
return ( !isTablet || openBranchingPanel ?
|
2023-12-05 23:34:40 +00:00
|
|
|
|
<Box sx={{ userSelect: "none", maxWidth: "350px", width: "100%" }}>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "15px",
|
|
|
|
|
padding: "18px",
|
|
|
|
|
background: "#fff",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
boxShadow: "0px 10px 30px #e7e7e7",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Switch
|
2023-12-13 23:08:31 +00:00
|
|
|
|
checked={openBranchingPanel}
|
2023-12-14 09:40:53 +00:00
|
|
|
|
onChange={
|
|
|
|
|
(e) => updateOpenBranchingPanel(e.target.checked)
|
2023-12-13 23:08:31 +00:00
|
|
|
|
}
|
2023-12-05 23:34:40 +00:00
|
|
|
|
sx={{
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 30,
|
|
|
|
|
padding: 0,
|
|
|
|
|
"& .MuiSwitch-switchBase": {
|
|
|
|
|
padding: 0,
|
|
|
|
|
margin: "2px",
|
|
|
|
|
transitionDuration: "300ms",
|
|
|
|
|
"&.Mui-checked": {
|
|
|
|
|
transform: "translateX(20px)",
|
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
"& + .MuiSwitch-track": {
|
|
|
|
|
backgroundColor: "#E8DCF9",
|
|
|
|
|
opacity: 1,
|
|
|
|
|
border: 0,
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled + .MuiSwitch-track": { opacity: 0.5 },
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled .MuiSwitch-thumb": {
|
|
|
|
|
color:
|
|
|
|
|
theme.palette.mode === "light"
|
|
|
|
|
? theme.palette.grey[100]
|
|
|
|
|
: theme.palette.grey[600],
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled + .MuiSwitch-track": {
|
|
|
|
|
opacity: theme.palette.mode === "light" ? 0.7 : 0.3,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"& .MuiSwitch-thumb": {
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
width: 25,
|
|
|
|
|
height: 25,
|
|
|
|
|
},
|
|
|
|
|
"& .MuiSwitch-track": {
|
|
|
|
|
borderRadius: 13,
|
|
|
|
|
backgroundColor:
|
|
|
|
|
theme.palette.mode === "light" ? "#E9E9EA" : "#39393D",
|
|
|
|
|
opacity: 1,
|
|
|
|
|
transition: theme.transitions.create(["background-color"], {
|
|
|
|
|
duration: 500,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography ref={ref} sx={{ fontWeight: "bold", color: "#4D4D4D" }}>
|
|
|
|
|
Логика ветвления
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{ color: "#4D4D4D", fontSize: "12px" }}>
|
|
|
|
|
Настройте связи между вопросами
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
{ openBranchingPanel && <QuestionsList /> }
|
|
|
|
|
</Box>
|
2023-12-14 09:40:53 +00:00
|
|
|
|
:
|
|
|
|
|
<></>
|
2023-12-05 23:34:40 +00:00
|
|
|
|
);
|
|
|
|
|
};
|