открытие модалки ветвления через стор(в процессе)
This commit is contained in:
parent
b656a3b3ae
commit
16468c601f
@ -19,7 +19,10 @@ interface Props {
|
||||
|
||||
export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: Props) {
|
||||
const params = Number(useParams().quizId);
|
||||
const {listQuestions, updateQuestionsList, createQuestion, removeQuestion} = questionStore()
|
||||
const {listQuestions, updateQuestionsList, createQuestion, removeQuestion, openedModalSettings} = questionStore()
|
||||
const openedModal = () => {
|
||||
|
||||
}
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Box
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Box, Typography, Link, useTheme, TextField, FormControl, InputAdornment, IconButton} from "@mui/material";
|
||||
import React from "react";
|
||||
import React, {useState} from "react";
|
||||
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
|
||||
import SwitchAnswerOptions from "./switchAnswerOptions";
|
||||
import ButtonsOptionsAndPict from "../ButtonsOptionsAndPict";
|
||||
@ -28,7 +28,9 @@ export default function AnswerOptions({totalIndex}: Props) {
|
||||
const SSHC = (data: string) => {
|
||||
setSwitchState(data)
|
||||
}
|
||||
|
||||
// const [openBranch, setOpenBranch] = useState(false);
|
||||
// const handleOpenBranch = () => setOpenBranch(true);
|
||||
// const handleCloseBranch = () => setOpenBranch(false);
|
||||
|
||||
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);
|
||||
|
||||
@ -66,12 +68,12 @@ export default function AnswerOptions({totalIndex}: Props) {
|
||||
sx={{ p: "0 0 20px 0" }}
|
||||
>
|
||||
<TextField
|
||||
value={Answer[index]}
|
||||
value={Answer[index].answer}
|
||||
fullWidth
|
||||
placeholder={"Добавьте ответ"}
|
||||
onChange={(e) => {
|
||||
const answerNew = Answer
|
||||
answerNew[index] = e.target.value
|
||||
answerNew[index].answer = e.target.value
|
||||
let clonContent = listQuestions[params][totalIndex].content
|
||||
clonContent.variants = answerNew
|
||||
updateQuestionsList(params, totalIndex, {content: clonContent})}}
|
||||
@ -96,7 +98,14 @@ export default function AnswerOptions({totalIndex}: Props) {
|
||||
horizontal: 'left',
|
||||
}}
|
||||
>
|
||||
<TextareaAutosize style={{margin: "10px"}} placeholder="Подсказка для этого ответа" />
|
||||
<TextareaAutosize style={{margin: "10px"}} placeholder="Подсказка для этого ответа" value={Answer[index].hints}
|
||||
onChange={(e) => {
|
||||
const answerNew = Answer
|
||||
answerNew[index].hints = e.target.value
|
||||
let clonContent = listQuestions[params][totalIndex].content
|
||||
clonContent.variants = answerNew
|
||||
updateQuestionsList(params, totalIndex, {content: clonContent})}}
|
||||
/>
|
||||
</Popover>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
@ -142,7 +151,7 @@ export default function AnswerOptions({totalIndex}: Props) {
|
||||
sx={{color: theme.palette.brightPurple.main}}
|
||||
onClick={() => {
|
||||
const answerNew = Answer
|
||||
answerNew.push("")
|
||||
answerNew.push({answer: "",})
|
||||
let clonContent = listQuestions[params][totalIndex].content
|
||||
clonContent.variants = answerNew
|
||||
updateQuestionsList(params, totalIndex, {content: clonContent})
|
||||
|
||||
@ -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<boolean>(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) => {
|
||||
@ -41,10 +41,9 @@ export default function BranchingQuestions() {
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Button onClick={handleOpen}>открыть</Button>
|
||||
<Modal
|
||||
open={open}
|
||||
onClose={handleClose}
|
||||
open={openBranch}
|
||||
onClose={handleCloseBranch}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
@ -260,7 +259,7 @@ export default function BranchingQuestions() {
|
||||
<Box sx={{ display: "flex", justifyContent: "end", gap: "10px" }}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={handleClose}
|
||||
onClick={handleCloseBranch}
|
||||
>
|
||||
Отмена
|
||||
</Button>
|
||||
|
||||
@ -6,6 +6,7 @@ interface QuestionStore {
|
||||
updateQuestionsList: (id: number, index: number, values: unknown) => void;
|
||||
removeQuestion: any;
|
||||
createQuestion: (id: number) => void;
|
||||
openedModalSettings: any
|
||||
}
|
||||
|
||||
export const questionStore = create<QuestionStore>()(
|
||||
@ -39,7 +40,11 @@ export const questionStore = create<QuestionStore>()(
|
||||
"page": 0,
|
||||
"content": {
|
||||
variants: [
|
||||
|
||||
{
|
||||
answer: "",
|
||||
answerLong: "",
|
||||
hints: ""
|
||||
}
|
||||
],
|
||||
own: true,
|
||||
multi: true
|
||||
@ -64,6 +69,14 @@ export const questionStore = create<QuestionStore>()(
|
||||
state[id] = array
|
||||
set({listQuestions: state});
|
||||
},
|
||||
|
||||
openedModalSettings: [],
|
||||
|
||||
createOpenedModalSettings: (id: number) => {
|
||||
const state = get()["openedModalSettings"] || [];
|
||||
state.push(String(id))
|
||||
set({openedModalSettings: state})
|
||||
}
|
||||
}),
|
||||
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user