2023-03-30 18:39:59 +00:00
|
|
|
|
import {
|
2023-04-15 09:10:59 +00:00
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
FormControl,
|
|
|
|
|
FormControlLabel,
|
|
|
|
|
IconButton,
|
|
|
|
|
Link,
|
|
|
|
|
Modal,
|
|
|
|
|
Radio,
|
|
|
|
|
RadioGroup,
|
|
|
|
|
Typography,
|
|
|
|
|
useTheme,
|
2023-03-30 18:39:59 +00:00
|
|
|
|
} from "@mui/material";
|
|
|
|
|
import * as React from "react";
|
2023-04-15 09:10:59 +00:00
|
|
|
|
import { useState } from "react";
|
2023-08-15 12:20:09 +00:00
|
|
|
|
import { questionStore, resetSomeField } from "@root/questions";
|
2023-08-15 14:04:01 +00:00
|
|
|
|
import { Select } from "./Select";
|
2023-05-10 17:35:30 +00:00
|
|
|
|
import DeleteIcon from "@icons/questionsPage/deleteIcon";
|
2023-05-03 23:25:35 +00:00
|
|
|
|
import RadioCheck from "@ui_kit/RadioCheck";
|
|
|
|
|
import RadioIcon from "@ui_kit/RadioIcon";
|
2023-08-15 14:04:01 +00:00
|
|
|
|
import InfoIcon from "@icons/Info";
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
|
|
|
|
export default function BranchingQuestions() {
|
2023-08-15 14:04:01 +00:00
|
|
|
|
const [value, setValue] = useState("1");
|
|
|
|
|
const [conditionSelected, setConditionSelected] = useState<boolean>(false);
|
2023-07-30 15:35:40 +00:00
|
|
|
|
const { openedModalSettings } = questionStore();
|
|
|
|
|
const theme = useTheme();
|
2023-07-14 18:29:09 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
const [condition, setCondition] = useState<boolean>(false);
|
2023-07-14 18:29:09 +00:00
|
|
|
|
const handleClose = () => {
|
2023-07-30 15:35:40 +00:00
|
|
|
|
resetSomeField({ openedModalSettings: "" });
|
|
|
|
|
};
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
const handleChangeRadio = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
setValue((event.target as HTMLInputElement).value);
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Modal
|
2023-07-14 18:29:09 +00:00
|
|
|
|
open={Boolean(openedModalSettings)}
|
2023-07-14 12:21:03 +00:00
|
|
|
|
onClose={handleClose}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
aria-labelledby="modal-modal-title"
|
|
|
|
|
aria-describedby="modal-modal-description"
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute" as "absolute",
|
2023-08-15 12:20:09 +00:00
|
|
|
|
overflow: "hidden",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
top: "50%",
|
|
|
|
|
left: "50%",
|
|
|
|
|
transform: "translate(-50%, -50%)",
|
|
|
|
|
maxWidth: "620px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
bgcolor: "background.paper",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
boxShadow: 24,
|
|
|
|
|
p: 0,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-15 12:20:09 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
background: "#F2F3F7",
|
|
|
|
|
padding: "25px",
|
|
|
|
|
height: "70px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography sx={{ color: "#9A9AAF" }}>()</Typography>
|
|
|
|
|
<InfoIcon width={24} height={24} />
|
|
|
|
|
</Box>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "30px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-15 14:04:01 +00:00
|
|
|
|
<Select
|
|
|
|
|
items={["Показать", "Скрыть"]}
|
|
|
|
|
sx={{ maxWidth: "140px" }}
|
|
|
|
|
/>
|
2023-08-15 12:20:09 +00:00
|
|
|
|
<Typography sx={{ color: theme.palette.grey2.main }}>
|
|
|
|
|
если в ответе на вопрос
|
|
|
|
|
</Typography>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
{condition ? (
|
2023-08-15 12:20:09 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: "20px",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
height: "100%",
|
|
|
|
|
bgcolor: "#F2F3F7",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
2023-08-15 14:04:01 +00:00
|
|
|
|
pb: "5px",
|
2023-08-15 12:20:09 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-15 14:04:01 +00:00
|
|
|
|
<Typography sx={{ color: "#4D4D4D", fontWeight: "500" }}>
|
|
|
|
|
Условие 1
|
|
|
|
|
</Typography>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
<IconButton sx={{ borderRadius: "6px", padding: "2px" }}>
|
2023-07-30 15:35:40 +00:00
|
|
|
|
<DeleteIcon color={"#4D4D4D"} />
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
2023-08-15 14:04:01 +00:00
|
|
|
|
<Select
|
|
|
|
|
empty
|
|
|
|
|
items={["Условие 1", "Условие 2", "Условие 3"]}
|
|
|
|
|
onChange={() => setConditionSelected(true)}
|
|
|
|
|
sx={{ marginBottom: "15px" }}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
/>
|
2023-08-15 14:04:01 +00:00
|
|
|
|
{conditionSelected && (
|
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{ display: "flex", alignItems: "center", pb: "10px" }}
|
|
|
|
|
>
|
|
|
|
|
<Typography sx={{ color: "#4D4D4D", fontWeight: "500" }}>
|
|
|
|
|
Дан ответ
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{ color: "#7E2AEA", pl: "10px" }}>
|
|
|
|
|
(Укажите один или несколько вариантов)
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Select
|
|
|
|
|
empty
|
|
|
|
|
items={["Условие 1", "Условие 2", "Условие 3"]}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
) : (
|
|
|
|
|
""
|
|
|
|
|
)}
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "baseline",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Link
|
|
|
|
|
component="button"
|
|
|
|
|
variant="body2"
|
2023-08-15 12:20:09 +00:00
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
marginBottom: "10px",
|
|
|
|
|
}}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
onClick={() => setCondition(true)}
|
|
|
|
|
>
|
|
|
|
|
Добавить условие
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
<FormControl>
|
|
|
|
|
<RadioGroup
|
|
|
|
|
aria-labelledby="demo-controlled-radio-buttons-group"
|
|
|
|
|
name="controlled-radio-buttons-group"
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleChangeRadio}
|
|
|
|
|
>
|
|
|
|
|
<FormControlLabel
|
|
|
|
|
sx={{ color: theme.palette.grey2.main }}
|
|
|
|
|
value="1"
|
2023-08-15 12:20:09 +00:00
|
|
|
|
control={
|
|
|
|
|
<Radio
|
|
|
|
|
checkedIcon={<RadioCheck />}
|
|
|
|
|
icon={<RadioIcon />}
|
|
|
|
|
/>
|
|
|
|
|
}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
label="Все условия обязательны"
|
|
|
|
|
/>
|
|
|
|
|
<FormControlLabel
|
|
|
|
|
sx={{ color: theme.palette.grey2.main }}
|
|
|
|
|
value="2"
|
2023-08-15 12:20:09 +00:00
|
|
|
|
control={
|
|
|
|
|
<Radio
|
|
|
|
|
checkedIcon={<RadioCheck />}
|
|
|
|
|
icon={<RadioIcon />}
|
|
|
|
|
/>
|
|
|
|
|
}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
label="Обязательно хотя бы одно условие"
|
|
|
|
|
/>
|
|
|
|
|
</RadioGroup>
|
|
|
|
|
</FormControl>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{ display: "flex", justifyContent: "end", gap: "10px" }}>
|
2023-08-15 12:20:09 +00:00
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
onClick={handleClose}
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "130px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
Отмена
|
2023-05-10 17:35:30 +00:00
|
|
|
|
</Button>
|
2023-08-15 12:20:09 +00:00
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "130px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Готово
|
|
|
|
|
</Button>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</Modal>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|