функция для добавления в стор вопросов состояния модалки

This commit is contained in:
Tamara 2023-07-14 15:21:03 +03:00
parent 16468c601f
commit 5705e9aa42
3 changed files with 18 additions and 13 deletions

@ -19,9 +19,11 @@ interface Props {
export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: Props) { export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: Props) {
const params = Number(useParams().quizId); 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 = () => { const openedModal = () => {
createOpenedModalSettings({openedModalSettings: "открыто"})
console.log(openedModalSettings)
} }
const theme = useTheme(); const theme = useTheme();
return ( return (
@ -67,6 +69,7 @@ export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }:
<MiniButtonSetting <MiniButtonSetting
onClick={() => { onClick={() => {
SSHC("branching"); SSHC("branching");
openedModal()
}} }}
sx={{ sx={{
backgroundColor: switchState === "branching" ? theme.palette.brightPurple.main : "transparent", backgroundColor: switchState === "branching" ? theme.palette.brightPurple.main : "transparent",
@ -79,6 +82,7 @@ export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }:
<MiniButtonSetting <MiniButtonSetting
onClick={() => { onClick={() => {
SSHC("image"); SSHC("image");
}} }}
sx={{ sx={{
backgroundColor: switchState === "image" ? theme.palette.brightPurple.main : "transparent", backgroundColor: switchState === "image" ? theme.palette.brightPurple.main : "transparent",

@ -24,10 +24,10 @@ import RadioIcon from "@ui_kit/RadioIcon";
export default function BranchingQuestions() { export default function BranchingQuestions() {
const theme = useTheme(); const theme = useTheme();
// const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [condition, setCondition] = useState<boolean>(false); const [condition, setCondition] = useState<boolean>(false);
// const handleOpen = () => setOpen(true); const handleOpen = () => setOpen(true);
// const handleClose = () => setOpen(false); const handleClose = () => setOpen(false);
const [display, setDisplay] = React.useState("1"); const [display, setDisplay] = React.useState("1");
const handleChange = (event: SelectChangeEvent) => { const handleChange = (event: SelectChangeEvent) => {
@ -42,8 +42,8 @@ export default function BranchingQuestions() {
return ( return (
<> <>
<Modal <Modal
open={openBranch} open={open}
onClose={handleCloseBranch} onClose={handleClose}
aria-labelledby="modal-modal-title" aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description" aria-describedby="modal-modal-description"
> >
@ -259,7 +259,7 @@ export default function BranchingQuestions() {
<Box sx={{ display: "flex", justifyContent: "end", gap: "10px" }}> <Box sx={{ display: "flex", justifyContent: "end", gap: "10px" }}>
<Button <Button
variant="outlined" variant="outlined"
onClick={handleCloseBranch} onClick={handleClose}
> >
Отмена Отмена
</Button> </Button>

@ -7,6 +7,7 @@ interface QuestionStore {
removeQuestion: any; removeQuestion: any;
createQuestion: (id: number) => void; createQuestion: (id: number) => void;
openedModalSettings: any openedModalSettings: any
createOpenedModalSettings: (data: any) => void;
} }
export const questionStore = create<QuestionStore>()( export const questionStore = create<QuestionStore>()(
@ -70,12 +71,12 @@ export const questionStore = create<QuestionStore>()(
set({listQuestions: state}); set({listQuestions: state});
}, },
openedModalSettings: [], openedModalSettings: "",
createOpenedModalSettings: (id: number) => { createOpenedModalSettings: (data:any) => {
const state = get()["openedModalSettings"] || []; const oldState = get()
state.push(String(id)) const newStore = {...oldState, ...data}
set({openedModalSettings: state}) set(newStore)
} }
}), }),