fix: bugs

This commit is contained in:
IlyaDoronin 2023-08-25 14:18:25 +03:00
parent 9a2288adae
commit 96c58dfd18
2 changed files with 19 additions and 11 deletions

@ -1,23 +1,31 @@
import { useState, useEffect } from "react";
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 type { ChangeEvent } from "react";
interface Props {
totalIndex: number;
}
export default function ResponseSettings({ totalIndex }: Props) {
const params = Number(useParams().quizId);
const [checked, setChecked] = useState(false);
const { listQuestions } = questionStore();
const [checked, setChecked] = React.useState([true, false]);
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setChecked([checked[0], event.target.checked]);
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
setChecked(event.target.checked);
};
useEffect(() => {
if (listQuestions[totalIndex].content.innerName.length) {
setChecked(true);
}
}, []);
return (
<Box sx={{ display: "flex" }}>
<Box sx={{ padding: "20px", display: "flex", flexDirection: "column" }}>
@ -62,18 +70,18 @@ export default function ResponseSettings({ totalIndex }: Props) {
<Box sx={{ display: "flex" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={checked[1]}
checked={checked}
handleChange={handleChange}
/>{" "}
<InfoIcon />
</Box>
{checked[1] && (
{checked && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[totalIndex].description}
onChange={(e) => {
text={listQuestions[totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[totalIndex].content;
clonContent.innerName = e.target.value;
clonContent.innerName = target.value;
updateQuestionsList(totalIndex, { content: clonContent });
}}
/>

@ -165,7 +165,7 @@ export default function BranchingQuestions({
</Box>
<Select
empty
activeItemIndex={Number(request.id) || -1}
activeItemIndex={request.id ? Number(request.id) : -1}
items={STIPULATIONS}
onChange={(stipulation) => {
const clonContent = listQuestions[totalIndex].content;