fix: branching error
This commit is contained in:
parent
c9f9f3a4b0
commit
71f749e892
@ -4,6 +4,7 @@ export const QUIZ_QUESTION_BASE: Omit<QuizQuestionInitial, "id"> = {
|
||||
title: "",
|
||||
type: "nonselected",
|
||||
expanded: true,
|
||||
openedModalSettings: false,
|
||||
required: false,
|
||||
deleted: false,
|
||||
deleteTimeoutId: 0,
|
||||
|
@ -48,6 +48,7 @@ export interface QuizQuestionBase {
|
||||
title: string;
|
||||
type: string;
|
||||
expanded: boolean;
|
||||
openedModalSettings: boolean;
|
||||
required: boolean;
|
||||
deleted: boolean;
|
||||
deleteTimeoutId: number;
|
||||
|
@ -17,7 +17,6 @@ import { CopyIcon } from "../../assets/icons/questionsPage/CopyIcon";
|
||||
|
||||
import {
|
||||
questionStore,
|
||||
resetSomeField,
|
||||
copyQuestion,
|
||||
removeQuestionForce,
|
||||
updateQuestionsList,
|
||||
@ -45,7 +44,7 @@ export default function ButtonsOptions({
|
||||
totalIndex,
|
||||
}: Props) {
|
||||
const quizId = Number(useParams().quizId);
|
||||
const { openedModalSettings, listQuestions } = questionStore();
|
||||
const { listQuestions } = questionStore();
|
||||
const { listQuizes } = quizStore();
|
||||
const [openedReallyChangingModal, setOpenedReallyChangingModal] =
|
||||
useState<boolean>(false);
|
||||
@ -59,7 +58,9 @@ export default function ButtonsOptions({
|
||||
}, [listQuestions]);
|
||||
|
||||
const openedModal = () => {
|
||||
resetSomeField({ openedModalSettings: "open" });
|
||||
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
|
||||
openedModalSettings: true,
|
||||
});
|
||||
};
|
||||
|
||||
const theme = useTheme();
|
||||
|
@ -21,7 +21,6 @@ import {
|
||||
questionStore,
|
||||
copyQuestion,
|
||||
removeQuestion,
|
||||
resetSomeField,
|
||||
removeQuestionForce,
|
||||
updateQuestionsList,
|
||||
} from "@root/questions";
|
||||
@ -62,7 +61,9 @@ export default function ButtonsOptionsAndPict({
|
||||
}, [listQuestions]);
|
||||
|
||||
const openedModal = () => {
|
||||
resetSomeField({ openedModalSettings: "open" });
|
||||
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
|
||||
openedModalSettings: true,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -15,11 +15,7 @@ import {
|
||||
Typography,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import {
|
||||
questionStore,
|
||||
resetSomeField,
|
||||
updateQuestionsList,
|
||||
} from "@root/questions";
|
||||
import { questionStore, updateQuestionsList } from "@root/questions";
|
||||
import { Select } from "./Select";
|
||||
|
||||
import RadioCheck from "@ui_kit/RadioCheck";
|
||||
@ -48,7 +44,7 @@ export default function BranchingQuestions({
|
||||
const [title, setTitle] = useState<string>("");
|
||||
const [titleInputWidth, setTitleInputWidth] = useState<number>(0);
|
||||
const quizId = Number(useParams().quizId);
|
||||
const { openedModalSettings, listQuestions } = questionStore();
|
||||
const { listQuestions } = questionStore();
|
||||
const titleRef = useRef<HTMLDivElement>(null);
|
||||
const question = listQuestions[quizId][totalIndex] as QuizQuestionBase;
|
||||
|
||||
@ -57,20 +53,17 @@ export default function BranchingQuestions({
|
||||
}, [title]);
|
||||
|
||||
const handleClose = () => {
|
||||
resetSomeField({ openedModalSettings: "" });
|
||||
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
|
||||
openedModalSettings: false,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
open={Boolean(openedModalSettings)}
|
||||
onClose={handleClose}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
<Modal open={question.openedModalSettings} onClose={handleClose}>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute" as "absolute",
|
||||
position: "absolute",
|
||||
overflow: "hidden",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
|
@ -24,7 +24,6 @@ setAutoFreeze(false);
|
||||
|
||||
interface QuestionStore {
|
||||
listQuestions: Record<string, AnyQuizQuestion[]>;
|
||||
openedModalSettings: string;
|
||||
}
|
||||
|
||||
let isFirstPartialize = true;
|
||||
@ -34,7 +33,6 @@ export const questionStore = create<QuestionStore>()(
|
||||
devtools(
|
||||
() => ({
|
||||
listQuestions: {},
|
||||
openedModalSettings: "",
|
||||
}),
|
||||
{
|
||||
name: "Question",
|
||||
@ -341,10 +339,6 @@ export const removeQuestion = (quizId: number, index: number) => {
|
||||
questionStore.setState({ listQuestions: questionListClone });
|
||||
};
|
||||
|
||||
export const resetSomeField = (data: Record<string, string>) => {
|
||||
questionStore.setState(data);
|
||||
};
|
||||
|
||||
export const findQuestionById = (quizId: number) => {
|
||||
let found = null;
|
||||
questionStore
|
||||
|
Loading…
Reference in New Issue
Block a user