удаление безтипового вопроса

This commit is contained in:
Nastya 2023-12-28 00:51:20 +03:00
parent ce5fea6a7e
commit 3f95f32ec9
4 changed files with 227 additions and 217 deletions

@ -26,7 +26,7 @@ import { useQuestionsStore } from "@root/questions/store";
import { updateOpenedModalSettingsId } from "@root/uiTools/actions";
import { updateRootContentId } from "@root/quizes/actions";
import { useUiTools } from "@root/uiTools/store";
import {useState} from "react";
import { useState } from "react";
import { updateSomeWorkBackend } from "@root/uiTools/actions";
import { DeleteFunction } from "@utils/deleteFunc";
@ -282,7 +282,11 @@ export default function ButtonsOptions({
<IconButton
sx={{ borderRadius: "6px", padding: "2px" }}
onClick={() => {
if(question.content.rule.parentId.length !== 0) {
if (question.type === null) {
console.log("удаление безтипового")
deleteQuestion(question.id);
}
if (question.content.rule.parentId.length !== 0) {
setOpenDelete(true)
} else {
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
@ -305,7 +309,7 @@ export default function ButtonsOptions({
background: "#FFFFFF",
}}
>
<Typography variant="h6" sx={{textAlign: "center"}}>
<Typography variant="h6" sx={{ textAlign: "center" }}>
Вы удаляете вопрос, участвующий в ветвлении. Все его потомки потеряют данные ветвления. Вы уверены, что хотите удалить вопрос?
</Typography>
<Box

@ -315,6 +315,10 @@ export default function ButtonsOptionsAndPict({
<IconButton
sx={{ borderRadius: "6px", padding: "2px" }}
onClick={() => {
if (question.type === null) {
console.log("удаление безтипового")
deleteQuestion(question.id);
}
if(question.content.rule.parentId.length !== 0) {
setOpenDelete(true)
} else {

@ -66,7 +66,7 @@ interface Props {
}
export default function QuestionsPageCard({ question, draggableProps, isDragging, index }: Props) {
const maxLengthTextField = 225;
const maxLengthTextField = 225;
const { questions } = useQuestionsStore();
const [plusVisible, setPlusVisible] = useState<boolean>(false);
@ -277,6 +277,10 @@ const maxLengthTextField = 225;
margin: "0 5px 0 10px",
}}
onClick={() => {
if (question.type === null) {
console.log("удаление безтипового")
deleteQuestion(question.id);
}
if (question.content.rule.parentId.length !== 0) {
setOpenDelete(true);
} else {

@ -60,8 +60,6 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) =
const result = questions.find(q => q.type === "result" && q.content.rule.parentId === question.content.id)
if (result) await deleteQuestion(result.id);
} else {
await deleteQuestion(question.id);
}
}