From 5705e9aa42cb6f9741f72ef8e95da63d6ee20819 Mon Sep 17 00:00:00 2001 From: Tamara Date: Fri, 14 Jul 2023 15:21:03 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D1=81=D1=82=D0=BE=D1=80=20=D0=B2?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=BE=D1=81=D0=BE=D0=B2=20=D1=81=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D1=8F=D0=BD=D0=B8=D1=8F=20=D0=BC=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Questions/ButtonsOptionsAndPict.tsx | 8 ++++++-- src/pages/Questions/branchingQuestions.tsx | 12 ++++++------ src/stores/questions.ts | 11 ++++++----- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/pages/Questions/ButtonsOptionsAndPict.tsx b/src/pages/Questions/ButtonsOptionsAndPict.tsx index 629283d3..6746f564 100644 --- a/src/pages/Questions/ButtonsOptionsAndPict.tsx +++ b/src/pages/Questions/ButtonsOptionsAndPict.tsx @@ -19,9 +19,11 @@ interface Props { export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: Props) { const params = Number(useParams().quizId); - const {listQuestions, updateQuestionsList, createQuestion, removeQuestion, openedModalSettings} = questionStore() + const {listQuestions, updateQuestionsList, createQuestion, removeQuestion, openedModalSettings, createOpenedModalSettings} = questionStore() + const idQuestions = listQuestions[params].id const openedModal = () => { - + createOpenedModalSettings({openedModalSettings: "открыто"}) + console.log(openedModalSettings) } const theme = useTheme(); return ( @@ -67,6 +69,7 @@ export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: { SSHC("branching"); + openedModal() }} sx={{ backgroundColor: switchState === "branching" ? theme.palette.brightPurple.main : "transparent", @@ -79,6 +82,7 @@ export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: { SSHC("image"); + }} sx={{ backgroundColor: switchState === "image" ? theme.palette.brightPurple.main : "transparent", diff --git a/src/pages/Questions/branchingQuestions.tsx b/src/pages/Questions/branchingQuestions.tsx index f672cb2f..9585983e 100644 --- a/src/pages/Questions/branchingQuestions.tsx +++ b/src/pages/Questions/branchingQuestions.tsx @@ -24,10 +24,10 @@ import RadioIcon from "@ui_kit/RadioIcon"; export default function BranchingQuestions() { const theme = useTheme(); - // const [open, setOpen] = useState(false); + const [open, setOpen] = useState(false); const [condition, setCondition] = useState(false); - // const handleOpen = () => setOpen(true); - // const handleClose = () => setOpen(false); + const handleOpen = () => setOpen(true); + const handleClose = () => setOpen(false); const [display, setDisplay] = React.useState("1"); const handleChange = (event: SelectChangeEvent) => { @@ -42,8 +42,8 @@ export default function BranchingQuestions() { return ( <> @@ -259,7 +259,7 @@ export default function BranchingQuestions() { diff --git a/src/stores/questions.ts b/src/stores/questions.ts index 7e9b821e..89034003 100644 --- a/src/stores/questions.ts +++ b/src/stores/questions.ts @@ -7,6 +7,7 @@ interface QuestionStore { removeQuestion: any; createQuestion: (id: number) => void; openedModalSettings: any + createOpenedModalSettings: (data: any) => void; } export const questionStore = create()( @@ -70,12 +71,12 @@ export const questionStore = create()( set({listQuestions: state}); }, - openedModalSettings: [], + openedModalSettings: "", - createOpenedModalSettings: (id: number) => { - const state = get()["openedModalSettings"] || []; - state.push(String(id)) - set({openedModalSettings: state}) + createOpenedModalSettings: (data:any) => { + const oldState = get() + const newStore = {...oldState, ...data} + set(newStore) } }),