diff --git a/src/pages/Questions/Select.tsx b/src/pages/Questions/Select.tsx index 231db4a2..95f879ad 100644 --- a/src/pages/Questions/Select.tsx +++ b/src/pages/Questions/Select.tsx @@ -13,29 +13,25 @@ import type { SelectChangeEvent, SxProps } from "@mui/material"; type SelectProps = { items: string[]; empty?: boolean; - onChange?: (num: number) => void; + onChange?: (item: string, num: number) => void; sx?: SxProps; }; export const Select = ({ items, empty, onChange, sx }: SelectProps) => { const [activeItem, setActiveItem] = useState(empty ? -1 : 0); - const theme = useTheme(); const handleChange = (event: SelectChangeEvent) => { - setActiveItem(Number(event.target.value)); - onChange?.(Number(event.target.value)); + const activeItemIndex = Number(event.target.value); + setActiveItem(activeItemIndex); + onChange?.(items[activeItemIndex], activeItemIndex); }; return ( (false); const [conditionSelected, setConditionSelected] = useState(false); const { openedModalSettings } = questionStore(); const theme = useTheme(); - const [condition, setCondition] = useState(false); + useEffect(() => { + updateBranchState({ action: ACTIONS[0], condition: CONDITIONS[0] }); + }, []); + const handleClose = () => { resetSomeField({ openedModalSettings: "" }); }; - const handleChangeRadio = (event: React.ChangeEvent) => { - setValue((event.target as HTMLInputElement).value); - }; return ( <> setConditionSelected(true)} + items={STIPULATION} + onChange={(stipulation) => { + setConditionSelected(true); + updateBranchState({ stipulation }); + }} sx={{ marginBottom: "15px" }} /> {conditionSelected && ( <> Дан ответ @@ -136,7 +152,8 @@ export default function BranchingQuestions() {