diff --git a/package.json b/package.json
index 43f2c04c..f79c3503 100755
--- a/package.json
+++ b/package.json
@@ -24,6 +24,7 @@
"cypress-file-upload": "^5.0.8",
"cytoscape": "^3.26.0",
"cytoscape-popper": "^2.0.0",
+ "date-fns": "^3.0.4",
"dayjs": "^1.11.10",
"emoji-mart": "^5.5.2",
"file-saver": "^2.0.5",
diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx
index b3cd0c55..8289ccf1 100644
--- a/src/pages/Questions/BranchingMap/CsComponent.tsx
+++ b/src/pages/Questions/BranchingMap/CsComponent.tsx
@@ -118,37 +118,42 @@ function CsComponent({
}, [modalQuestionTargetContentId])
const addNode = ({ parentNodeContentId, targetNodeContentId }: { parentNodeContentId: string, targetNodeContentId?: string }) => {
+ if (quiz) {
- //запрещаем работу родителя-ребенка если это один и тот же вопрос
- if (parentNodeContentId === targetNodeContentId) return
+ //запрещаем работу родителя-ребенка если это один и тот же вопрос
+ if (parentNodeContentId === targetNodeContentId) return
- const cy = cyRef?.current
- const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length
- //если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа
- const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyTypedQuizQuestion
- if (Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) {
- clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
- cy?.data('changed', true)
- createResult(quiz?.backendId, targetQuestion.content.id)
- const es = cy?.add([
- {
- data: {
- id: targetQuestion.content.id,
- label: targetQuestion.title === "" || targetQuestion.title === " " ? "noname" : targetQuestion.title
+ const cy = cyRef?.current
+ const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length
+ //если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа
+ const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyTypedQuizQuestion
+ if (Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) {
+ clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
+ cy?.data('changed', true)
+ createResult(quiz.backendId, targetQuestion.content.id)
+ const es = cy?.add([
+ {
+ data: {
+ id: targetQuestion.content.id,
+ label: targetQuestion.title === "" || targetQuestion.title === " " ? "noname" : targetQuestion.title
+ }
+ },
+ {
+ data: {
+ source: parentNodeContentId,
+ target: targetQuestion.content.id
+ }
}
- },
- {
- data: {
- source: parentNodeContentId,
- target: targetQuestion.content.id
- }
- }
- ])
- cy?.layout(layoutOptions).run()
- cy?.center(es)
+ ])
+ cy?.layout(layoutOptions).run()
+ cy?.center(es)
+ } else {
+ enqueueSnackbar("Добавляемый вопрос не найден")
+ }
+
} else {
- enqueueSnackbar("Добавляемый вопрос не найден")
+ enqueueSnackbar("Квиз не найден")
}
}
@@ -232,7 +237,7 @@ function CsComponent({
return (
<>
+ mb="20px">
-
+
-
+
>
);
};
function Clear() {
const quiz = useCurrentQuiz();
- updateRootContentId(quiz?.id, "")
+ if (quiz) {
+ updateRootContentId(quiz?.id, "");
+ }
clearRuleForAll()
return <>>
}
diff --git a/src/pages/Questions/DeleteNodeModal/index.tsx b/src/pages/Questions/DeleteNodeModal/index.tsx
index 0e6a21fc..56c64de2 100644
--- a/src/pages/Questions/DeleteNodeModal/index.tsx
+++ b/src/pages/Questions/DeleteNodeModal/index.tsx
@@ -1,61 +1,82 @@
-import { useState, useRef, useEffect, useLayoutEffect } from "react";
+import { useState, useEffect } from "react";
import {
Box,
Button,
- FormControl,
FormControlLabel,
- Link,
Modal,
- Radio,
- RadioGroup,
- Tooltip,
Typography,
useTheme,
Checkbox,
} from "@mui/material";
-import { enqueueSnackbar } from "notistack";
-import {
- AnyTypedQuizQuestion,
- createBranchingRuleMain,
-} from "../../../model/questionTypes/shared";
-import { Select } from "../Select";
+import { isSameDay, isSameMonth, isSameYear, getHours } from "date-fns";
-import RadioCheck from "@ui_kit/RadioCheck";
-import RadioIcon from "@ui_kit/RadioIcon";
-import InfoIcon from "@icons/Info";
-import { DeleteIcon } from "@icons/questionsPage/deleteIcon";
-
-import {
- getQuestionById,
- getQuestionByContentId,
- updateQuestion,
-} from "@root/questions/actions";
-import { updateOpenedModalSettingsId } from "@root/uiTools/actions";
+import { getQuestionByContentId } from "@root/questions/actions";
+import { updateDeleteId } from "@root/uiTools/actions";
import { useUiTools } from "@root/uiTools/store";
-export const DeleteNodeModal = () => {
- const { deleteNodeId } = useUiTools();
- const targetQuestion = getQuestionById(deleteNodeId);
+import { CheckboxIcon } from "@icons/Checkbox";
- const saveData = () => {
- // if (parentQuestion !== null) {
- // updateQuestion(
- // parentQuestion.content.id,
- // (question) => (question.content = parentQuestion.content)
- // );
- // }
- // handleClose();
+type DeleteNodeModalProps = {
+ removeNode?: (id: string) => void;
+};
+
+export const DeleteNodeModal = ({ removeNode }: DeleteNodeModalProps) => {
+ const [skipModal, setSkipModal] = useState(false);
+ const { deleteNodeId } = useUiTools();
+ const targetQuestion = getQuestionByContentId(deleteNodeId);
+ const theme = useTheme();
+
+ useEffect(() => {
+ const isSkipModal = getIsSkipModal();
+
+ if (isSkipModal) {
+ deleteNode();
+ }
+ }, [deleteNodeId]);
+
+ const getLastDeletionNodeTime = () =>
+ Number(localStorage.getItem("lastDeletionNodeTime") || 0);
+
+ const updateLastDeletionNodeTime = () => {
+ const now = new Date().getTime();
+
+ localStorage.setItem("lastDeletionNodeTime", String(now));
+ };
+
+ const getIsSkipModal = () => {
+ const lastDeletionNodeTime = getLastDeletionNodeTime();
+ const now = new Date().getTime();
+
+ console.log("hours", getHours(lastDeletionNodeTime));
+
+ const sameYear = isSameYear(lastDeletionNodeTime, now);
+ const sameMonth = isSameMonth(lastDeletionNodeTime, now);
+ const sameDay = isSameDay(lastDeletionNodeTime, now);
+
+ return sameYear && sameMonth && sameDay;
+ };
+
+ const deleteNode = () => {
+ if (skipModal) {
+ updateLastDeletionNodeTime();
+ }
+
+ if (deleteNodeId) {
+ removeNode?.(deleteNodeId || "");
+ }
+ handleClose();
};
const handleClose = () => {
- updateOpenedModalSettingsId();
+ updateDeleteId("");
};
return (
<>
-
+
{
alignItems: "center",
}}
>
-
- {targetQuestion?.title}
-
-
-
-
-
-
+ {targetQuestion?.title}
-
+
+ Вы правда хотите удалить этот узел? Данные его настроек и настроек
+ его потомков будут утеряны.
+
{
+ }
+ checkedIcon={}
+ onChange={(_, value) => setSkipModal(value)}
+ checked={skipModal}
+ />
+ }
+ label="Не спрашивать больше сегодня"
+ sx={{
+ userSelect: "none",
+ margin: "0 0 10px",
+ color: theme.palette.grey2.main,
+ }}
+ />
>
diff --git a/src/stores/uiTools/store.ts b/src/stores/uiTools/store.ts
index c8cd887f..52803348 100644
--- a/src/stores/uiTools/store.ts
+++ b/src/stores/uiTools/store.ts
@@ -10,7 +10,6 @@ export type UiTools = {
canCreatePublic: boolean;
whyCantCreatePublic: Record//ид вопроса и список претензий к нему
openModalInfoWhyCantCreate: boolean;
-lastDeletionNodeTime: number | null;
deleteNodeId: string | null;
};
export type WhyCantCreatePublic = {
@@ -28,7 +27,6 @@ const initialState: UiTools = {
canCreatePublic: false,
whyCantCreatePublic: {},
openModalInfoWhyCantCreate: false,
-lastDeletionNodeTime: null,
deleteNodeId: null,
};
diff --git a/yarn.lock b/yarn.lock
index 5c6fbdc9..2b3e7508 100755
--- a/yarn.lock
+++ b/yarn.lock
@@ -4204,6 +4204,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
+date-fns@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.0.4.tgz#56eb7916d8d4666bf9be168ef84bed0deef1077c"
+ integrity sha512-+daptVi95nJ/D4TPS7/gbUqneVMA0Izr4qYAsL2ZZwtcDtEP8Zge765mbXhTqWYdTSG79/VtbBigQTluiE9DBQ==
+
dayjs@^1.10.4, dayjs@^1.11.10:
version "1.11.10"
resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz"