переключение на графы и вывод модалки ветвления

This commit is contained in:
Tamara 2023-12-04 19:33:45 +03:00
parent 9ee2786956
commit 14efd54369
3 changed files with 7 additions and 6 deletions

@ -21,6 +21,7 @@ import SettingIcon from "../../assets/icons/questionsPage/settingIcon";
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared"; import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
import { updateOpenedModalSettingsId } from "@root/questions/actions"; import { updateOpenedModalSettingsId } from "@root/questions/actions";
import {enqueueSnackbar} from "notistack"; import {enqueueSnackbar} from "notistack";
import {useQuestionsStore} from "@root/questions/store";
interface Props { interface Props {
@ -38,14 +39,13 @@ export default function ButtonsOptions({
const theme = useTheme(); const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down(790)); const isMobile = useMediaQuery(theme.breakpoints.down(790));
const isWrappMiniButtonSetting = useMediaQuery(theme.breakpoints.down(920)); const isWrappMiniButtonSetting = useMediaQuery(theme.breakpoints.down(920));
const {openBranchingPanel} = useQuestionsStore.getState()
const openedModal = () => { const openedModal = () => {
updateOpenedModalSettingsId(question.id) updateOpenedModalSettingsId(question.id)
}; };
const handleClickBranching = (_, value) => { const handleClickBranching = (_, value) => {
const parentId = question.content.rule.parentId const parentId = question.content.rule.parentId
console.log(parentId.length)
if (parentId.length === 0 ){ if (parentId.length === 0 ){
return enqueueSnackbar("Вопрос не учавствует в ветвлении") return enqueueSnackbar("Вопрос не учавствует в ветвлении")
} }
@ -54,6 +54,7 @@ export default function ButtonsOptions({
} }
if (parentId.length !== 0) { if (parentId.length !== 0) {
setTimeout(() => updateOpenBranchingPanel(!value), 10) setTimeout(() => updateOpenBranchingPanel(!value), 10)
openedModal()
} }
} }
@ -94,7 +95,7 @@ export default function ButtonsOptions({
), ),
title: "Ветвление", title: "Ветвление",
value: "branching", value: "branching",
myFunc: openedModal, handleClickBranching myFunc: handleClickBranching(question.id, openBranchingPanel),
}, },
]; ];

@ -55,7 +55,6 @@ export default function ButtonsOptionsAndPict({
const handleClickBranching = (_, value) => { const handleClickBranching = (_, value) => {
const parentId = question.content.rule.parentId const parentId = question.content.rule.parentId
console.log(parentId.length)
if (parentId.length === 0 ) { if (parentId.length === 0 ) {
return enqueueSnackbar("Вопрос не учавствует в ветвлении") return enqueueSnackbar("Вопрос не учавствует в ветвлении")
} }
@ -64,6 +63,7 @@ export default function ButtonsOptionsAndPict({
} }
if (parentId.length !== 0) { if (parentId.length !== 0) {
setTimeout(() => updateOpenBranchingPanel(!value), 10) setTimeout(() => updateOpenBranchingPanel(!value), 10)
updateOpenedModalSettingsId(question.id)
} }
} }
@ -203,7 +203,6 @@ export default function ButtonsOptionsAndPict({
onMouseEnter={() => setButtonHover("branching")} onMouseEnter={() => setButtonHover("branching")}
onMouseLeave={() => setButtonHover("")} onMouseLeave={() => setButtonHover("")}
onClick={() => { onClick={() => {
updateOpenedModalSettingsId(question.id)
handleClickBranching(question.id, openBranchingPanel) handleClickBranching(question.id, openBranchingPanel)
}} }}
sx={{ sx={{

@ -24,7 +24,8 @@ export default function QuestionsPage() {
const { openedModalSettingsId } = useQuestionsStore(); const { openedModalSettingsId } = useQuestionsStore();
const isMobile = useMediaQuery(theme.breakpoints.down(660)); const isMobile = useMediaQuery(theme.breakpoints.down(660));
const quiz = useCurrentQuiz(); const quiz = useCurrentQuiz();
const openBranchingPanel = useQuestionsStore.getState() const {openBranchingPanel} = useQuestionsStore.getState()
if (!quiz) return null; if (!quiz) return null;
return ( return (