fix: 2 bugs

This commit is contained in:
IlyaDoronin 2023-10-09 11:33:46 +03:00
parent 81fd62c85b
commit 9aa6fbf411
2 changed files with 6 additions and 5 deletions

@ -129,9 +129,9 @@ export const ChooseAnswerModal = ({
onClick={() => { onClick={() => {
setOpenModal(false); setOpenModal(false);
const question = listQuestions[quizId][totalIndex]; const question = { ...listQuestions[quizId][totalIndex] };
removeQuestionForce(quizId, totalIndex); removeQuestionForce(quizId, question.id);
createQuestion(quizId, selectedValue, totalIndex); createQuestion(quizId, selectedValue, totalIndex);
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, { updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
expanded: question.expanded, expanded: question.expanded,

@ -17,7 +17,7 @@ import {
questionStore, questionStore,
updateQuestionsList, updateQuestionsList,
createQuestion, createQuestion,
removeQuestion, removeQuestionForce,
} from "@root/questions"; } from "@root/questions";
import type { import type {
@ -110,12 +110,13 @@ export default function TypeQuestions({ totalIndex }: Props) {
<QuestionsMiniButton <QuestionsMiniButton
key={title} key={title}
onClick={() => { onClick={() => {
const question = listQuestions[quizId][totalIndex]; const question = { ...listQuestions[quizId][totalIndex] };
removeQuestion(quizId, totalIndex); removeQuestionForce(quizId, question.id);
createQuestion(quizId, value, totalIndex); createQuestion(quizId, value, totalIndex);
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, { updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
expanded: question.expanded, expanded: question.expanded,
type: value,
}); });
}} }}
icon={icon} icon={icon}