diff --git a/src/pages/Questions/ButtonsOptionsAndPict.tsx b/src/pages/Questions/ButtonsOptionsAndPict.tsx index 7fd1e614..26b64933 100644 --- a/src/pages/Questions/ButtonsOptionsAndPict.tsx +++ b/src/pages/Questions/ButtonsOptionsAndPict.tsx @@ -10,7 +10,6 @@ import DeleteIcon from "../../assets/icons/questionsPage/deleteIcon"; import ImgIcon from "../../assets/icons/questionsPage/imgIcon"; import { useParams } from "react-router-dom"; import { questionStore, removeQuestion, resetSomeField } from "@root/questions"; -import { branchStore } from "@root/branches"; import "./ButtonsOptionsAndPict.css"; @@ -27,7 +26,6 @@ export default function ButtonsOptionsAndPict({ }: Props) { const params = Number(useParams().quizId); const { openedModalSettings } = questionStore(); - const { branch } = branchStore(); const theme = useTheme(); const openedModal = () => { diff --git a/src/pages/Questions/branchingQuestions.tsx b/src/pages/Questions/branchingQuestions.tsx index 0a798be6..ee281397 100644 --- a/src/pages/Questions/branchingQuestions.tsx +++ b/src/pages/Questions/branchingQuestions.tsx @@ -1,4 +1,3 @@ -import { useEffect } from "react"; import { Box, Button, @@ -18,7 +17,6 @@ import { resetSomeField, updateQuestionsList, } from "@root/questions"; -import { branchStore, updateBranchState } from "@root/branches"; import { Select } from "./Select"; import DeleteIcon from "@icons/questionsPage/deleteIcon"; @@ -42,20 +40,8 @@ export default function BranchingQuestions({ totalIndex, }: BranchingQuestionsProps) { const { openedModalSettings, listQuestions } = questionStore(); - const { branch } = branchStore(); const theme = useTheme(); - useEffect(() => { - updateBranchState({ - action: listQuestions[totalIndex].content.rule.show - ? ACTIONS[0] - : ACTIONS[1], - condition: listQuestions[totalIndex].content.rule.or - ? CONDITIONS[0] - : CONDITIONS[1], - }); - }, []); - const handleClose = () => { resetSomeField({ openedModalSettings: "" }); }; @@ -120,7 +106,6 @@ export default function BranchingQuestions({ const clonContent = listQuestions[totalIndex].content; clonContent.rule.show = action === ACTIONS[0]; updateQuestionsList(totalIndex, { content: clonContent }); - updateBranchState({ action }); }} /> @@ -180,7 +165,6 @@ export default function BranchingQuestions({ }; updateQuestionsList(totalIndex, { content: clonContent }); - updateBranchState({ stipulation }); }} sx={{ marginBottom: "15px" }} /> @@ -225,7 +209,6 @@ export default function BranchingQuestions({ updateQuestionsList(totalIndex, { content: clonContent, }); - updateBranchState({ answer }); }} sx={{ marginBottom: "10px", @@ -295,14 +278,13 @@ export default function BranchingQuestions({ { const clonContent = listQuestions[totalIndex].content; clonContent.rule.or = target.value === CONDITIONS[0]; updateQuestionsList(totalIndex, { content: clonContent }); - updateBranchState({ - condition: CONDITIONS[Number(target.value)], - }); }} > {CONDITIONS.map((condition, index) => ( diff --git a/src/stores/branches.ts b/src/stores/branches.ts deleted file mode 100644 index 56d0747e..00000000 --- a/src/stores/branches.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { create } from "zustand"; - -export type Branch = { - action: string; - stipulation: string; - answer: string; - condition: string; -}; - -interface BranchStore { - branch: Branch; -} - -export const branchStore = create()(() => ({ - branch: { - action: "", - stipulation: "", - answer: "", - condition: "", - }, -})); - -export const updateBranchState = (data: Partial) => { - const state = { ...branchStore.getState().branch }; - - branchStore.setState({ branch: { ...state, ...data } }); -};