diff --git a/src/pages/Questions/answerOptions/responseSettings.tsx b/src/pages/Questions/answerOptions/responseSettings.tsx index fa1ea5b7..24410a50 100644 --- a/src/pages/Questions/answerOptions/responseSettings.tsx +++ b/src/pages/Questions/answerOptions/responseSettings.tsx @@ -1,61 +1,84 @@ -import {Box, Typography} from "@mui/material"; +import { Box, Typography } from "@mui/material"; import CustomCheckbox from "@ui_kit/CustomCheckbox"; import InfoIcon from "../../../assets/icons/InfoIcon"; import * as React from "react"; import CustomTextField from "@ui_kit/CustomTextField"; -import {useParams} from "react-router-dom"; -import {questionStore, updateQuestionsList} from "@root/questions"; +import { useParams } from "react-router-dom"; +import { questionStore, updateQuestionsList } from "@root/questions"; interface Props { - totalIndex: number, + totalIndex: number; } -export default function ResponseSettings({totalIndex}: Props) { - const params = Number(useParams().quizId); - const {listQuestions} = questionStore() - const [checked, setChecked] = React.useState([true, false]); - const handleChange = (event: React.ChangeEvent) => { - setChecked([checked[0], event.target.checked, ]); - }; +export default function ResponseSettings({ totalIndex }: Props) { + const params = Number(useParams().quizId); + const { listQuestions } = questionStore(); + const [checked, setChecked] = React.useState([true, false]); + const handleChange = (event: React.ChangeEvent) => { + setChecked([checked[0], event.target.checked]); + }; - return ( - - - Настройки ответов - - { - let clonContent = listQuestions[totalIndex].content - clonContent.multi = e.target.checked - updateQuestionsList( totalIndex, {content: clonContent}) - }} - /> - { - let clonContent = listQuestions[totalIndex].content - clonContent.own = e.target.checked - updateQuestionsList(totalIndex, {content: clonContent}) - }} - /> - - - Настройки вопросов - { - updateQuestionsList(totalIndex, {required: !e.target.checked}) - console.log(listQuestions[totalIndex].required)}}/> - - - - {checked[1] ? - updateQuestionsList(totalIndex, {description: e.target.value})}/> - : - <> - } - + return ( + + + Настройки ответов + { + let clonContent = listQuestions[totalIndex].content; + clonContent.large = e.target.checked; + updateQuestionsList(totalIndex, { content: clonContent }); + }} + /> + { + let clonContent = listQuestions[totalIndex].content; + clonContent.multi = e.target.checked; + updateQuestionsList(totalIndex, { content: clonContent }); + }} + /> + { + let clonContent = listQuestions[totalIndex].content; + clonContent.own = e.target.checked; + updateQuestionsList(totalIndex, { content: clonContent }); + }} + /> + + + Настройки вопросов + { + updateQuestionsList(totalIndex, { required: !e.target.checked }); + }} + /> + + {" "} + - ); -}; \ No newline at end of file + {checked[1] && ( + { + let clonContent = listQuestions[totalIndex].content; + clonContent.innerName = e.target.value; + updateQuestionsList(totalIndex, { content: clonContent }); + }} + /> + )} + + + ); +} diff --git a/src/stores/questions.ts b/src/stores/questions.ts index 6b80d10c..ba990860 100644 --- a/src/stores/questions.ts +++ b/src/stores/questions.ts @@ -17,13 +17,16 @@ export interface Question { page: number; content: { variants: Variants[]; - own: boolean; + large: boolean; multi: boolean; + own: boolean; + innerName: string; }; version: number; parent_ids: number[]; created_at: string; updated_at: string; + expanded: boolean; } interface QuestionStore { @@ -74,13 +77,16 @@ export const createQuestion = (id: number) => { hints: "", }, ], - own: true, - multi: true, + large: false, + multi: false, + own: false, + innerName: "", }, version: 0, parent_ids: [0], created_at: "", updated_at: "", + expanded: false, }); questionStore.setState({ listQuestions: newData }); };