удаление нод нормально регулирует резулты

This commit is contained in:
Nastya 2023-12-28 19:34:23 +03:00
parent 6d2fd7da4f
commit 2deae1bab2

@ -72,8 +72,8 @@ export const useRemoveNode = ({
//Ищём родителя //Ищём родителя
const parentQuestion = getQuestionByContentId(parentQuestionContentId); const parentQuestion = getQuestionByContentId(parentQuestionContentId);
if (parentQuestion.content.rule.children.length === 1) { //если у родителя больше нет потомков
//Делаем результат родителя активным //Делаем результат родителя активным
const parentResult = trashQuestions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestionContentId) const parentResult = trashQuestions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestionContentId)
if (parentResult) { if (parentResult) {
updateQuestion(parentResult.content.id, q => { updateQuestion(parentResult.content.id, q => {
@ -83,6 +83,9 @@ export const useRemoveNode = ({
createResult(quiz?.backendId, parentQuestionContentId) createResult(quiz?.backendId, parentQuestionContentId)
} }
}
//чистим rule родителя //чистим rule родителя
if (!parentQuestion?.type) { if (!parentQuestion?.type) {
return; return;