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