diff --git a/src/pages/Questions/answerOptions/responseSettings.tsx b/src/pages/Questions/answerOptions/responseSettings.tsx index 24410a50..6a465748 100644 --- a/src/pages/Questions/answerOptions/responseSettings.tsx +++ b/src/pages/Questions/answerOptions/responseSettings.tsx @@ -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) => { - setChecked([checked[0], event.target.checked]); + + const handleChange = (event: ChangeEvent) => { + setChecked(event.target.checked); }; + useEffect(() => { + if (listQuestions[totalIndex].content.innerName.length) { + setChecked(true); + } + }, []); + return ( @@ -62,18 +70,18 @@ export default function ResponseSettings({ totalIndex }: Props) { {" "} - {checked[1] && ( + {checked && ( { + 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 }); }} /> diff --git a/src/pages/Questions/branchingQuestions.tsx b/src/pages/Questions/branchingQuestions.tsx index 92a9ca94..0a798be6 100644 --- a/src/pages/Questions/branchingQuestions.tsx +++ b/src/pages/Questions/branchingQuestions.tsx @@ -165,7 +165,7 @@ export default function BranchingQuestions({