import { useEffect } from "react"; import { Box, Button, Chip, FormControl, FormControlLabel, IconButton, Link, Modal, Radio, RadioGroup, Typography, useTheme, } from "@mui/material"; import { questionStore, resetSomeField, updateQuestionsList, } from "@root/questions"; import { branchStore, updateBranchState } from "@root/branches"; import { Select } from "./Select"; import DeleteIcon from "@icons/questionsPage/deleteIcon"; import RadioCheck from "@ui_kit/RadioCheck"; import RadioIcon from "@ui_kit/RadioIcon"; import InfoIcon from "@icons/Info"; type BranchingQuestionsProps = { totalIndex: number; }; const ACTIONS = ["Показать", "Скрыть"]; const STIPULATIONS = ["Условие 1", "Условие 2", "Условие 3"]; const ANSWERS = ["Ответ 1", "Ответ 2", "Ответ 3"]; const CONDITIONS = [ "Все условия обязательны", "Обязательно хотя бы одно условие", ]; export default function BranchingQuestions({ totalIndex, }: BranchingQuestionsProps) { const { openedModalSettings, listQuestions } = questionStore(); const { branch } = branchStore(); const theme = useTheme(); useEffect(() => { updateBranchState({ action: listQuestions[totalIndex].content.rule.show ? ACTIONS[0] : ACTIONS[1], condition: listQuestions[totalIndex].content.rule.or ? CONDITIONS[0] : CONDITIONS[1], }); }, []); const handleClose = () => { resetSomeField({ openedModalSettings: "" }); }; return ( <> () { const clonContent = listQuestions[totalIndex].content; clonContent.rule.reqs[index] = { id: String( STIPULATIONS.findIndex((item) => item.includes(stipulation) ) ), vars: request.vars, }; updateQuestionsList(totalIndex, { content: clonContent }); updateBranchState({ stipulation }); }} sx={{ marginBottom: "15px" }} /> {request.id && ( <> Дан ответ (Укажите один или несколько вариантов)