diff --git a/src/pages/Questions/QuestionSwitchWindowTool.tsx b/src/pages/Questions/QuestionSwitchWindowTool.tsx index 10372180..e60f50ca 100644 --- a/src/pages/Questions/QuestionSwitchWindowTool.tsx +++ b/src/pages/Questions/QuestionSwitchWindowTool.tsx @@ -7,42 +7,27 @@ import { useQuestionsStore } from "@root/questions/store"; import { useUiTools } from "@root/uiTools/store"; import { useQuestions } from "@root/questions/hooks"; import { useCurrentQuiz } from "@root/quizes/hooks"; -import { updateSomeWorkBackend } from "@root/uiTools/actions"; -import { - copyQuestion, - deleteQuestion, - deleteQuestionWithTimeout, - clearRuleForAll, - updateQuestion, - getQuestionByContentId, -} from "@root/questions/actions"; -import { updateRootContentId } from "@root/quizes/actions"; - -import type { AnyTypedQuizQuestion } from "@model/questionTypes/shared"; -import { DeleteFunction } from "@utils/deleteFunc"; import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions"; interface Props { openBranchingPage: boolean; - setOpenBranchingPage: (a:boolean) => void; + setOpenBranchingPage: (a: boolean) => void; } -export const QuestionSwitchWindowTool = ({ - openBranchingPage, - setOpenBranchingPage}:Props) => { +export const QuestionSwitchWindowTool = ({ openBranchingPage, setOpenBranchingPage }: Props) => { const { questions } = useQuestionsStore.getState(); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down(600)); const quiz = useCurrentQuiz(); - console.log("Я компонент в котором отвечала") + console.log("Я компонент в котором отвечала"); const openBranchingPageHC = () => { if (!openBranchingPage) { - deleteTimeoutedQuestions(questions, quiz) + deleteTimeoutedQuestions(questions, quiz); } - setOpenBranchingPage(!openBranchingPage) - } + setOpenBranchingPage(!openBranchingPage); + }; return ( - - {openBranchingPage ? : } - - + {openBranchingPage ? : } + {openBranchingPage && ( + + )} ); }; diff --git a/src/pages/Questions/QuestionsPage.tsx b/src/pages/Questions/QuestionsPage.tsx index c33752a6..e5ae8a7c 100755 --- a/src/pages/Questions/QuestionsPage.tsx +++ b/src/pages/Questions/QuestionsPage.tsx @@ -15,12 +15,10 @@ import { useUiTools } from "@root/uiTools/store"; interface Props { openBranchingPage: boolean; - setOpenBranchingPage: (a:boolean) => void; + setOpenBranchingPage: (a: boolean) => void; } -export default function QuestionsPage({ - openBranchingPage, - setOpenBranchingPage}:Props) { +export default function QuestionsPage({ openBranchingPage, setOpenBranchingPage }: Props) { const theme = useTheme(); const { openedModalSettingsId, openBranchingPanel } = useUiTools(); const isMobile = useMediaQuery(theme.breakpoints.down(660)); @@ -62,10 +60,7 @@ export default function QuestionsPage({ Свернуть всё - + void +let init: () => void; export default function EditPage() { const quiz = useCurrentQuiz(); const { editQuizId } = useQuizStore(); const { questions } = useQuestionsStore(); - console.log('quiz ',quiz); + console.log("quiz ", quiz); console.log(questions); useEffect(() => { const getData = async () => { @@ -86,26 +76,18 @@ export default function EditPage() { if ( !questions?.find( - (q) => - (q.type === "result" && q.content.includes(':"line"')) || - q.content.includes(":'line'") + (q) => (q.type === "result" && q.content.includes(':"line"')) || q.content.includes(":'line'") ) ) { createResult(quiz?.backendId, "line"); - console.log("Я не нашёл линейный резулт и собираюсь создать новый") + console.log("Я не нашёл линейный резулт и собираюсь создать новый"); } } - }; getData(); }, []); - const { - openBranchingPanel, - whyCantCreatePublic, - canCreatePublic, - showConfirmLeaveModal, - } = useUiTools(); + const { openBranchingPanel, whyCantCreatePublic, canCreatePublic, showConfirmLeaveModal } = useUiTools(); const theme = useTheme(); const navigate = useNavigate(); const currentStep = useQuizStore((state) => state.currentStep); @@ -119,10 +101,10 @@ export default function EditPage() { const openBranchingPageHC = () => { if (!openBranchingPage) { - deleteTimeoutedQuestions(questions, quiz) + deleteTimeoutedQuestions(questions, quiz); } - setOpenBranchingPage(old => !old) - } + setOpenBranchingPage((old) => !old); + }; useEffect(() => { if (editQuizId === null) navigate("/list"); @@ -137,21 +119,18 @@ export default function EditPage() { [] ); - const updateQuestionHint = useDebouncedCallback( - (questions: AnyTypedQuizQuestion[]) => { - const problems = checkQuestionHint(questions); - useUiTools.setState({ whyCantCreatePublic: problems }); - if (Object.keys(problems).length > 0) { - updateQuiz(quiz?.id, (state) => { - state.status = "stop"; - }); - updateCanCreatePublic(false); - } else { - updateCanCreatePublic(true); - } - }, - 600 - ); + const updateQuestionHint = useDebouncedCallback((questions: AnyTypedQuizQuestion[]) => { + const problems = checkQuestionHint(questions); + useUiTools.setState({ whyCantCreatePublic: problems }); + if (Object.keys(problems).length > 0) { + updateQuiz(quiz?.id, (state) => { + state.status = "stop"; + }); + updateCanCreatePublic(false); + } else { + updateCanCreatePublic(true); + } + }, 600); useEffect(() => { updateQuestionHint(questions); @@ -175,6 +154,8 @@ export default function EditPage() { }; if (!quizConfig) return <>; + + const isConditionMet = [1].includes(currentStep) && !openBranchingPanel && quizConfig.type !== "form"; return ( <> {/*хедер*/} @@ -308,45 +289,44 @@ export default function EditPage() { sx={{ background: theme.palette.background.default, width: "100%", - padding: isMobile ? "16px 16px 140px 16px" : "25px 25px 140px 25px", - height: "calc(100vh - 80px)", - overflow: "auto", - boxSizing: "border-box", }} > - {/* Выбор текущей страницы редактирования чего-либо находится здесь */} - {quizConfig && ( - <> - - - - )} - + - {[1].includes(currentStep) && - !openBranchingPanel && - quizConfig.type !== "form" && ( + boxSizing: "border-box", + }} + > + {/* Выбор текущей страницы редактирования чего-либо находится здесь */} + {quizConfig && ( + <> + + + + )} + + + {isConditionMet && ( - - Логика ветвления - + Логика ветвления )} - {!canCreatePublic && quiz.config.type !== "form" ? ( - - ) : ( - + {!canCreatePublic && quiz.config.type !== "form" ? ( - - )} + ) : ( + + + + )} - - {quiz?.status === "start" && ( - + updateQuiz(quiz?.id, (state) => { + state.status = quiz?.status === "start" ? "stop" : "start"; + }) + : () => updateModalInfoWhyCantCreate(true) + } > - https://hbpn.link/{quiz.qid} - - )} + {quiz?.status === "start" ? "Стоп" : "Старт"} + + {quiz?.status === "start" && ( + + https://hbpn.link/{quiz.qid} + + )} +