diff --git a/src/model/quizSettings.ts b/src/model/quizSettings.ts index bcbc8838..f33d87d9 100644 --- a/src/model/quizSettings.ts +++ b/src/model/quizSettings.ts @@ -164,7 +164,7 @@ export const defaultQuizConfig: QuizConfig = { logo: null, originalLogo: null, background: { - type: null, + type: "image", desktop: null, originalDesktop: null, mobile: null, diff --git a/src/pages/Questions/BranchingMap/CsNodeButtons.tsx b/src/pages/Questions/BranchingMap/CsNodeButtons.tsx index 6c6b7656..bbeaf5e6 100644 --- a/src/pages/Questions/BranchingMap/CsNodeButtons.tsx +++ b/src/pages/Questions/BranchingMap/CsNodeButtons.tsx @@ -80,18 +80,19 @@ export default function CsNodeButtons({ csElements, cyRef }: Props) { cleardragQuestionContentId(); }} />, - (!csElement.data.isRoot && !isQuestionProhibited(csElement.data.qtype)) && ( - { - const buttonData = buttonRefsById.current[csElement.data.id]; - if (buttonData) buttonData.settings = r; - }} - onClick={() => { - updateOpenedModalSettingsId(csElement.data.id,); - }} - /> - ), + !csElement.data.isRoot && + !isQuestionProhibited(csElement.data.qtype) && ( + { + const buttonData = buttonRefsById.current[csElement.data.id]; + if (buttonData) buttonData.settings = r; + }} + onClick={() => { + updateOpenedModalSettingsId(csElement.data.id); + }} + /> + ), //оболочка узла { setModalQuestionParentContentId(csElement.data.id); - console.log("csElement ", csElement) - setOpenedModalQuestions(!(isQuestionProhibited(csElement.data.type) && csElement.data.children > 0)); + console.log("csElement ", csElement); + setOpenedModalQuestions( + !( + isQuestionProhibited(csElement.data.type) && + csElement.data.children > 0 + ), + ); }} />, ])} diff --git a/src/pages/Questions/BranchingMap/helper.ts b/src/pages/Questions/BranchingMap/helper.ts index 94d59e60..adf021f3 100644 --- a/src/pages/Questions/BranchingMap/helper.ts +++ b/src/pages/Questions/BranchingMap/helper.ts @@ -73,9 +73,12 @@ export const storeToNodes = (questions: AnyTypedQuizQuestion[]) => { isRoot: question.content.rule.parentId === "root", id: question.content.id, label, - qtype: question.content.rule.parentId === "root" ? "root" : parentQuestion.type, + qtype: + question.content.rule.parentId === "root" + ? "root" + : parentQuestion.type, type: question.type, - children: question.content.rule.children.length + children: question.content.rule.children.length, }, classes: "multiline-auto", }); @@ -344,14 +347,15 @@ export const addNode = ({ const parentQuestion = { ...getQuestionByContentId(parentNodeContentId), } as AnyTypedQuizQuestion; - if ((parentQuestion.type !== undefined && isQuestionProhibited(parentQuestion.type)) && + if ( + parentQuestion.type !== undefined && + isQuestionProhibited(parentQuestion.type) && parentQuestion.content.rule.children.length > 0 ) { enqueueSnackbar("у вопроса этого типа может быть только 1 потомок"); return; } - //если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа const targetQuestion = { ...getQuestionByContentId( @@ -363,13 +367,14 @@ export const addNode = ({ clearDataAfterAddNode({ parentNodeContentId, targetQuestion }); createResult(useQuizStore.getState().editQuizId, targetQuestion.content.id); } else { - enqueueSnackbar("Добавляемый вопрос не найден. Перетащите вопрос из списка"); + enqueueSnackbar( + "Добавляемый вопрос не найден. Перетащите вопрос из списка", + ); } }; -export const isQuestionProhibited = (parentQType: string) => ( +export const isQuestionProhibited = (parentQType: string) => parentQType === "text" || parentQType === "date" || parentQType === "number" || - parentQType === "page" -) + parentQType === "page";