commit
5e241259f9
@ -5,6 +5,7 @@ import { GetQuestionListRequest, GetQuestionListResponse } from "@model/question
|
||||
import { EditQuestionRequest, EditQuestionResponse } from "@model/question/edit";
|
||||
import { DeleteQuestionRequest, DeleteQuestionResponse } from "@model/question/delete";
|
||||
import { CopyQuestionRequest, CopyQuestionResponse } from "@model/question/copy";
|
||||
import { replaceSpacesToEmptyLines } from "../utils/replaceSpacesToEmptyLines";
|
||||
|
||||
|
||||
const baseUrl = process.env.NODE_ENV === "production" ? "/squiz" : "https://squiz.pena.digital/squiz";
|
||||
@ -26,7 +27,7 @@ async function getQuestionList(body?: Partial<GetQuestionListRequest>) {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
return response.items;
|
||||
return replaceSpacesToEmptyLines(response.items);
|
||||
}
|
||||
|
||||
function editQuestion(body: EditQuestionRequest, signal?: AbortSignal) {
|
||||
|
@ -82,11 +82,11 @@ export const AnswerItem = ({
|
||||
setQuestionVariantAnswer(target.value || " ");
|
||||
}}
|
||||
onKeyDown={(event: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (disableKeyDown) {
|
||||
enqueueSnackbar("100 максимальное количество вопросов");
|
||||
} else if (event.code === "Enter" && !largeCheck) {
|
||||
// if (disableKeyDown) {
|
||||
// enqueueSnackbar("100 максимальное количество вопросов");
|
||||
// } else if (event.code === "Enter" && !largeCheck) {
|
||||
addQuestionVariant(questionId);
|
||||
}
|
||||
// }
|
||||
}}
|
||||
InputProps={{
|
||||
startAdornment: (
|
||||
|
@ -128,8 +128,6 @@ function CsComponent({
|
||||
if ((parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page")
|
||||
&& parentQuestion.content.rule.children.length === 1
|
||||
) {
|
||||
console.log(parentQuestion.content.rule.children)
|
||||
console.log("parentQuestion.content.rule.children.length === 1",parentQuestion.content.rule.children.length === 1)
|
||||
enqueueSnackbar("у вопроса этого типа может быть только 1 потомок")
|
||||
return
|
||||
}
|
||||
@ -140,8 +138,6 @@ function CsComponent({
|
||||
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
||||
cy?.data('changed', true)
|
||||
createResult(quiz.backendId, targetQuestion.content.id)
|
||||
console.log("Я собираюсь добавить узел из такого вопроса ", targetQuestion)
|
||||
console.log("Я собираюсь добавить узел у которого папаша вот такой ", parentNodeContentId)
|
||||
const es = cy?.add([
|
||||
{
|
||||
data: {
|
||||
@ -268,7 +264,12 @@ function CsComponent({
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
mb="20px">
|
||||
sx={{
|
||||
mb:"20px",
|
||||
display:'flex',
|
||||
justifyContent:"space-between"
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
sx={{
|
||||
height: "27px",
|
||||
|
@ -229,7 +229,11 @@ export const usePopper = ({
|
||||
updateOpenedModalSettingsId(item.id());
|
||||
});
|
||||
|
||||
console.log("собираюсь анализировать папашу")
|
||||
console.log("Тип папаши ", parentQuestion.type)
|
||||
if (parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page") {
|
||||
console.log("Шестерня должна быть невидимая")
|
||||
console.log("Тип папаши ", parentQuestion.type)
|
||||
gearElement.classList.add("popper-gear-none");
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,8 @@ export const useRemoveNode = ({
|
||||
|
||||
//Ищём родителя
|
||||
const parentQuestion = getQuestionByContentId(parentQuestionContentId);
|
||||
|
||||
//Делаем результат родителя активным
|
||||
if (parentQuestion.content.rule.children.length === 1) { //если у родителя больше нет потомков
|
||||
//Делаем результат родителя активным
|
||||
const parentResult = trashQuestions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestionContentId)
|
||||
if (parentResult) {
|
||||
updateQuestion(parentResult.content.id, q => {
|
||||
@ -83,6 +83,9 @@ export const useRemoveNode = ({
|
||||
createResult(quiz?.backendId, parentQuestionContentId)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//чистим rule родителя
|
||||
if (!parentQuestion?.type) {
|
||||
return;
|
||||
|
@ -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";
|
||||
|
||||
@ -118,116 +118,116 @@ export default function ButtonsOptions({
|
||||
>
|
||||
{buttonSetting.map(({ icon, title, value, myFunc }) => (
|
||||
<Box key={value}>
|
||||
{value === "branching" ?
|
||||
question.type === "page" || question.type === "text" || question.type === "date" || question.type === "number" ?
|
||||
<></>
|
||||
:
|
||||
(
|
||||
// <Tooltip
|
||||
// arrow
|
||||
// placement="right"
|
||||
// componentsProps={{
|
||||
// tooltip: {
|
||||
// sx: {
|
||||
// background: "#fff",
|
||||
// borderRadius: "6px",
|
||||
// color: "#9A9AAF",
|
||||
// boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)",
|
||||
// "& .MuiTooltip-arrow": {
|
||||
// color: "#FFF",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }}
|
||||
// title={
|
||||
// <Box>
|
||||
// <Typography
|
||||
// sx={{
|
||||
// color: "#4D4D4D",
|
||||
// fontWeight: "bold",
|
||||
// fontSize: "14px",
|
||||
// marginBottom: "10px",
|
||||
// }}
|
||||
// >
|
||||
// Будет показан при условии
|
||||
// </Typography>
|
||||
// <Typography sx={{ fontWeight: "bold", fontSize: "12px" }}>
|
||||
// Название
|
||||
// </Typography>
|
||||
// <Typography
|
||||
// sx={{
|
||||
// fontWeight: "bold",
|
||||
// fontSize: "12px",
|
||||
// marginBottom: "10px",
|
||||
// }}
|
||||
// >
|
||||
// Условие 1, Условие 2
|
||||
// </Typography>
|
||||
// <Typography sx={{ color: "#7E2AEA", fontSize: "12px" }}>
|
||||
// Все условия обязательны
|
||||
// </Typography>
|
||||
// </Box>
|
||||
// }
|
||||
// >
|
||||
<MiniButtonSetting
|
||||
key={title}
|
||||
onClick={() => {
|
||||
openedModal();
|
||||
// SSHC(value);
|
||||
// myFunc(question);
|
||||
}}
|
||||
sx={{
|
||||
display: quiz.config.type === "form" ? "none" : "flex",
|
||||
backgroundColor:
|
||||
switchState === value
|
||||
? theme.palette.brightPurple.main
|
||||
: "transparent",
|
||||
color:
|
||||
switchState === value
|
||||
? "#ffffff"
|
||||
: theme.palette.grey3.main,
|
||||
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
||||
height: "30px",
|
||||
"&:hover": {
|
||||
color: theme.palette.grey3.main,
|
||||
"& path": { stroke: theme.palette.grey3.main },
|
||||
},
|
||||
}}
|
||||
>
|
||||
{icon}
|
||||
{isWrappMiniButtonSetting ? null : title}
|
||||
</MiniButtonSetting>
|
||||
// </Tooltip>
|
||||
) : (
|
||||
<>
|
||||
<MiniButtonSetting
|
||||
key={title}
|
||||
onClick={() => {
|
||||
SSHC(value);
|
||||
myFunc();
|
||||
}}
|
||||
sx={{
|
||||
backgroundColor:
|
||||
switchState === value
|
||||
? theme.palette.brightPurple.main
|
||||
: "transparent",
|
||||
color:
|
||||
switchState === value
|
||||
? "#ffffff"
|
||||
: theme.palette.grey3.main,
|
||||
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
||||
height: "30px",
|
||||
"&:hover": {
|
||||
color: theme.palette.grey3.main,
|
||||
"& path": { stroke: theme.palette.grey3.main },
|
||||
},
|
||||
}}
|
||||
>
|
||||
{icon}
|
||||
{isWrappMiniButtonSetting ? null : title}
|
||||
</MiniButtonSetting>
|
||||
</>
|
||||
)}
|
||||
{value === "branching" ?
|
||||
question.type === "page" || question.type === "text" || question.type === "date" || question.type === "number" ?
|
||||
<></>
|
||||
:
|
||||
(
|
||||
// <Tooltip
|
||||
// arrow
|
||||
// placement="right"
|
||||
// componentsProps={{
|
||||
// tooltip: {
|
||||
// sx: {
|
||||
// background: "#fff",
|
||||
// borderRadius: "6px",
|
||||
// color: "#9A9AAF",
|
||||
// boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)",
|
||||
// "& .MuiTooltip-arrow": {
|
||||
// color: "#FFF",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }}
|
||||
// title={
|
||||
// <Box>
|
||||
// <Typography
|
||||
// sx={{
|
||||
// color: "#4D4D4D",
|
||||
// fontWeight: "bold",
|
||||
// fontSize: "14px",
|
||||
// marginBottom: "10px",
|
||||
// }}
|
||||
// >
|
||||
// Будет показан при условии
|
||||
// </Typography>
|
||||
// <Typography sx={{ fontWeight: "bold", fontSize: "12px" }}>
|
||||
// Название
|
||||
// </Typography>
|
||||
// <Typography
|
||||
// sx={{
|
||||
// fontWeight: "bold",
|
||||
// fontSize: "12px",
|
||||
// marginBottom: "10px",
|
||||
// }}
|
||||
// >
|
||||
// Условие 1, Условие 2
|
||||
// </Typography>
|
||||
// <Typography sx={{ color: "#7E2AEA", fontSize: "12px" }}>
|
||||
// Все условия обязательны
|
||||
// </Typography>
|
||||
// </Box>
|
||||
// }
|
||||
// >
|
||||
<MiniButtonSetting
|
||||
key={title}
|
||||
onClick={() => {
|
||||
openedModal();
|
||||
// SSHC(value);
|
||||
// myFunc(question);
|
||||
}}
|
||||
sx={{
|
||||
display: quiz.config.type === "form" ? "none" : "flex",
|
||||
backgroundColor:
|
||||
switchState === value
|
||||
? theme.palette.brightPurple.main
|
||||
: "transparent",
|
||||
color:
|
||||
switchState === value
|
||||
? "#ffffff"
|
||||
: theme.palette.grey3.main,
|
||||
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
||||
height: "30px",
|
||||
"&:hover": {
|
||||
color: theme.palette.grey3.main,
|
||||
"& path": { stroke: theme.palette.grey3.main },
|
||||
},
|
||||
}}
|
||||
>
|
||||
{icon}
|
||||
{isWrappMiniButtonSetting ? null : title}
|
||||
</MiniButtonSetting>
|
||||
// </Tooltip>
|
||||
) : (
|
||||
<>
|
||||
<MiniButtonSetting
|
||||
key={title}
|
||||
onClick={() => {
|
||||
SSHC(value);
|
||||
myFunc();
|
||||
}}
|
||||
sx={{
|
||||
backgroundColor:
|
||||
switchState === value
|
||||
? theme.palette.brightPurple.main
|
||||
: "transparent",
|
||||
color:
|
||||
switchState === value
|
||||
? "#ffffff"
|
||||
: theme.palette.grey3.main,
|
||||
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
||||
height: "30px",
|
||||
"&:hover": {
|
||||
color: theme.palette.grey3.main,
|
||||
"& path": { stroke: theme.palette.grey3.main },
|
||||
},
|
||||
}}
|
||||
>
|
||||
{icon}
|
||||
{isWrappMiniButtonSetting ? null : title}
|
||||
</MiniButtonSetting>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
))}
|
||||
{/* <>
|
||||
@ -282,7 +282,10 @@ export default function ButtonsOptions({
|
||||
<IconButton
|
||||
sx={{ borderRadius: "6px", padding: "2px" }}
|
||||
onClick={() => {
|
||||
if(question.content.rule.parentId.length !== 0) {
|
||||
if (question.type === null) {
|
||||
deleteQuestion(question.id);
|
||||
}
|
||||
if (question.content.rule.parentId.length !== 0) {
|
||||
setOpenDelete(true)
|
||||
} else {
|
||||
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
|
||||
@ -305,7 +308,7 @@ export default function ButtonsOptions({
|
||||
background: "#FFFFFF",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h6" sx={{textAlign: "center"}}>
|
||||
<Typography variant="h6" sx={{ textAlign: "center" }}>
|
||||
Вы удаляете вопрос, участвующий в ветвлении. Все его потомки потеряют данные ветвления. Вы уверены, что хотите удалить вопрос?
|
||||
</Typography>
|
||||
<Box
|
||||
|
@ -315,6 +315,9 @@ export default function ButtonsOptionsAndPict({
|
||||
<IconButton
|
||||
sx={{ borderRadius: "6px", padding: "2px" }}
|
||||
onClick={() => {
|
||||
if (question.type === null) {
|
||||
deleteQuestion(question.id);
|
||||
}
|
||||
if(question.content.rule.parentId.length !== 0) {
|
||||
setOpenDelete(true)
|
||||
} else {
|
||||
|
@ -59,35 +59,35 @@ import { updateSomeWorkBackend } from "@root/uiTools/actions";
|
||||
import { DeleteFunction } from "@utils/deleteFunc";
|
||||
|
||||
interface Props {
|
||||
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
||||
draggableProps: DraggableProvidedDragHandleProps | null | undefined;
|
||||
isDragging: boolean;
|
||||
index: number;
|
||||
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
||||
draggableProps: DraggableProvidedDragHandleProps | null | undefined;
|
||||
isDragging: boolean;
|
||||
index: number;
|
||||
}
|
||||
|
||||
export default function QuestionsPageCard({ question, draggableProps, isDragging, index }: Props) {
|
||||
const maxLengthTextField = 225;
|
||||
const maxLengthTextField = 225;
|
||||
|
||||
const { questions } = useQuestionsStore();
|
||||
const [plusVisible, setPlusVisible] = useState<boolean>(false);
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const { questions } = useQuestionsStore();
|
||||
const [plusVisible, setPlusVisible] = useState<boolean>(false);
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
|
||||
const [isTextFieldtActive, setIsTextFieldtActive] = useState(false);
|
||||
|
||||
const [openDelete, setOpenDelete] = useState<boolean>(false);
|
||||
const theme = useTheme();
|
||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
||||
const anchorRef = useRef(null);
|
||||
const quiz = useCurrentQuiz();
|
||||
const [openDelete, setOpenDelete] = useState<boolean>(false);
|
||||
const theme = useTheme();
|
||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
||||
const anchorRef = useRef(null);
|
||||
const quiz = useCurrentQuiz();
|
||||
|
||||
const setTitle = useDebouncedCallback((title) => {
|
||||
const updateQuestionFn = question.type === null ? updateUntypedQuestion : updateQuestion;
|
||||
const setTitle = useDebouncedCallback((title) => {
|
||||
const updateQuestionFn = question.type === null ? updateUntypedQuestion : updateQuestion;
|
||||
|
||||
updateQuestionFn(question.id, question => {
|
||||
question.title = title;
|
||||
});
|
||||
}, 200);
|
||||
updateQuestionFn(question.id, question => {
|
||||
question.title = title;
|
||||
});
|
||||
}, 200);
|
||||
|
||||
const handleInputFocus = () => {
|
||||
setIsTextFieldtActive(true);
|
||||
@ -98,7 +98,7 @@ const maxLengthTextField = 225;
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
return (
|
||||
<>
|
||||
<Paper
|
||||
id={question.id}
|
||||
@ -277,6 +277,9 @@ const maxLengthTextField = 225;
|
||||
margin: "0 5px 0 10px",
|
||||
}}
|
||||
onClick={() => {
|
||||
if (question.type === null) {
|
||||
deleteQuestion(question.id);
|
||||
}
|
||||
if (question.content.rule.parentId.length !== 0) {
|
||||
setOpenDelete(true);
|
||||
} else {
|
||||
@ -417,85 +420,85 @@ const maxLengthTextField = 225;
|
||||
}
|
||||
|
||||
const IconAndrom = (isExpanded: boolean, questionType: QuestionType | null) => {
|
||||
switch (questionType) {
|
||||
case "variant":
|
||||
return (
|
||||
<Answer
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "images":
|
||||
return (
|
||||
<OptionsPict
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "varimg":
|
||||
return (
|
||||
<OptionsAndPict
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "emoji":
|
||||
return (
|
||||
<Emoji
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "text":
|
||||
return (
|
||||
<Input
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "select":
|
||||
return (
|
||||
<DropDown
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "date":
|
||||
return (
|
||||
<Date
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "number":
|
||||
return (
|
||||
<Slider
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "file":
|
||||
return (
|
||||
<Download
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "page":
|
||||
return (
|
||||
<Page
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "rating":
|
||||
return (
|
||||
<RatingIcon
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return <></>;
|
||||
}
|
||||
switch (questionType) {
|
||||
case "variant":
|
||||
return (
|
||||
<Answer
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "images":
|
||||
return (
|
||||
<OptionsPict
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "varimg":
|
||||
return (
|
||||
<OptionsAndPict
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "emoji":
|
||||
return (
|
||||
<Emoji
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "text":
|
||||
return (
|
||||
<Input
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "select":
|
||||
return (
|
||||
<DropDown
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "date":
|
||||
return (
|
||||
<Date
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "number":
|
||||
return (
|
||||
<Slider
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "file":
|
||||
return (
|
||||
<Download
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "page":
|
||||
return (
|
||||
<Page
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "rating":
|
||||
return (
|
||||
<RatingIcon
|
||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return <></>;
|
||||
}
|
||||
};
|
||||
|
@ -20,7 +20,6 @@ export const QuestionSwitchWindowTool = ({ openBranchingPage, setOpenBranchingPa
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||
const quiz = useCurrentQuiz();
|
||||
console.log("Я компонент в котором отвечала");
|
||||
|
||||
const openBranchingPageHC = () => {
|
||||
if (!openBranchingPage) {
|
||||
|
@ -5,9 +5,9 @@ import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
|
||||
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
||||
import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx"
|
||||
import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx";
|
||||
import { NameplateLogo } from "@icons/NameplateLogo";
|
||||
import {modes} from "../../utils/themes/Publication/themePublication";
|
||||
import { modes } from "../../utils/themes/Publication/themePublication";
|
||||
|
||||
type ResultFormProps = {
|
||||
currentQuestion: AnyTypedQuizQuestion;
|
||||
@ -21,25 +21,25 @@ export const ResultForm = ({
|
||||
showContactForm,
|
||||
setShowContactForm,
|
||||
setShowResultForm,
|
||||
|
||||
}: ResultFormProps) => {
|
||||
const quiz = useCurrentQuiz();
|
||||
const mode = modes;
|
||||
const { questions } = useQuestionsStore();
|
||||
const resultQuestion = questions.find(
|
||||
const resultQuestion = (questions.find(
|
||||
(question) =>
|
||||
question.type === "result" &&
|
||||
(question.content.rule.parentId === "line" || currentQuestion.content.id)
|
||||
);
|
||||
|
||||
|
||||
|
||||
question.content.rule.parentId === currentQuestion.content.id
|
||||
) ||
|
||||
questions.find(
|
||||
(question) =>
|
||||
question.type === "result" && question.content.rule.parentId === "line"
|
||||
)) as AnyTypedQuizQuestion;
|
||||
|
||||
const followNextForm = () => {
|
||||
setShowResultForm(false);
|
||||
setShowContactForm(true);
|
||||
};
|
||||
if (resultQuestion === undefined) return <></>
|
||||
if (resultQuestion === undefined) return <></>;
|
||||
|
||||
return (
|
||||
<Box
|
||||
@ -50,10 +50,9 @@ export const ResultForm = ({
|
||||
justifyContent: "space-between",
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
pt: "28px"
|
||||
pt: "28px",
|
||||
}}
|
||||
>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
@ -62,53 +61,57 @@ export const ResultForm = ({
|
||||
width: "490px",
|
||||
}}
|
||||
>
|
||||
{
|
||||
!resultQuestion?.content.useImage &&
|
||||
resultQuestion.content.video &&
|
||||
{!resultQuestion?.content.useImage && resultQuestion.content.video && (
|
||||
<YoutubeEmbedIframe
|
||||
videoUrl={resultQuestion.content.video}
|
||||
containerSX={{
|
||||
width: "490px",
|
||||
height: "280px"
|
||||
height: "280px",
|
||||
}}
|
||||
/>
|
||||
}
|
||||
{
|
||||
resultQuestion?.content.useImage &&
|
||||
resultQuestion.content.back &&
|
||||
)}
|
||||
{resultQuestion?.content.useImage && resultQuestion.content.back && (
|
||||
<Box
|
||||
component='img'
|
||||
component="img"
|
||||
src={resultQuestion.content.back}
|
||||
sx={{
|
||||
width: "490px",
|
||||
height: "280px"
|
||||
height: "280px",
|
||||
}}
|
||||
>
|
||||
</Box>
|
||||
}
|
||||
{resultQuestion.description !== "" && resultQuestion.description !== " " && <Typography
|
||||
sx={{
|
||||
fontSize: "23px",
|
||||
fontWeight: 700,
|
||||
m: "20px 0"
|
||||
}}
|
||||
>{resultQuestion.description}</Typography>}
|
||||
></Box>
|
||||
)}
|
||||
{resultQuestion.description !== "" &&
|
||||
resultQuestion.description !== " " && (
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "23px",
|
||||
fontWeight: 700,
|
||||
m: "20px 0",
|
||||
}}
|
||||
>
|
||||
{resultQuestion.description}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<Typography
|
||||
sx={{
|
||||
m: "20px 0"
|
||||
m: "20px 0",
|
||||
}}
|
||||
>{resultQuestion.title || "Форма результатов"}
|
||||
>
|
||||
{resultQuestion.title || "Форма результатов"}
|
||||
</Typography>
|
||||
|
||||
{resultQuestion.content.text !== "" && resultQuestion.content.text !== " " && <Typography
|
||||
sx={{
|
||||
fontSize: "18px",
|
||||
m: "20px 0"
|
||||
}}
|
||||
>{resultQuestion.content.text}</Typography>}
|
||||
|
||||
|
||||
{resultQuestion.content.text !== "" &&
|
||||
resultQuestion.content.text !== " " && (
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "18px",
|
||||
m: "20px 0",
|
||||
}}
|
||||
>
|
||||
{resultQuestion.content.text}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box width="100%">
|
||||
@ -117,24 +120,30 @@ export const ResultForm = ({
|
||||
display: "flex",
|
||||
width: "100%",
|
||||
justifyContent: "end",
|
||||
px: "20px"
|
||||
px: "20px",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
mt: "15px"
|
||||
mt: "15px",
|
||||
}}
|
||||
>
|
||||
<NameplateLogo style={{ fontSize: "34px" }} />
|
||||
<Typography sx={{ fontSize: "20px", color: mode[quiz.config.theme] ? "#4D4D4D" : "#F5F7FF", whiteSpace: "nowrap" }}>Сделано на PenaQuiz</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "20px",
|
||||
color: mode[quiz.config.theme] ? "#4D4D4D" : "#F5F7FF",
|
||||
whiteSpace: "nowrap",
|
||||
}}
|
||||
>
|
||||
Сделано на PenaQuiz
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
</Box>
|
||||
|
||||
{
|
||||
quiz?.config.resultInfo.when === "before" &&
|
||||
{quiz?.config.resultInfo.when === "before" && (
|
||||
<>
|
||||
<Box
|
||||
sx={{
|
||||
@ -144,7 +153,7 @@ export const ResultForm = ({
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
p: "20px"
|
||||
p: "20px",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
@ -153,17 +162,15 @@ export const ResultForm = ({
|
||||
sx={{
|
||||
p: "10px 20px",
|
||||
width: "210px",
|
||||
height: "50px"
|
||||
height: "50px",
|
||||
}}
|
||||
>
|
||||
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
}
|
||||
)}
|
||||
</Box>
|
||||
|
||||
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
@ -130,7 +130,7 @@ export default function EditPage() {
|
||||
);
|
||||
|
||||
const updateQuestionHint = useDebouncedCallback((questions: AnyTypedQuizQuestion[]) => {
|
||||
const problems = checkQuestionHint(questions);
|
||||
const problems = checkQuestionHint(questions, quiz);
|
||||
useUiTools.setState({ whyCantCreatePublic: problems });
|
||||
if (Object.keys(problems).length > 0) {
|
||||
updateQuiz(quiz?.id, (state) => {
|
||||
@ -187,8 +187,6 @@ export default function EditPage() {
|
||||
}
|
||||
};
|
||||
|
||||
console.log(quiz?.status);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/*хедер*/}
|
||||
@ -223,6 +221,12 @@ export default function EditPage() {
|
||||
</Link>
|
||||
<FormControl fullWidth variant="standard">
|
||||
<TextField
|
||||
value={quiz.name}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.name = e.target.value;
|
||||
})
|
||||
}
|
||||
fullWidth
|
||||
id="project-name"
|
||||
placeholder="Название проекта окно"
|
||||
@ -461,7 +465,7 @@ export default function EditPage() {
|
||||
fontSize: "14px",
|
||||
lineHeight: "18px",
|
||||
height: "34px",
|
||||
background: quiz?.status === "start" ? "#7E2AEA" : "#FA5B0E",
|
||||
background: buttonText === "Опубликовано" ? "#FA5B0E" : "#7E2AEA",
|
||||
}}
|
||||
onClick={handleClickStatusQuiz}
|
||||
>
|
||||
|
@ -7,6 +7,14 @@ import { useLayoutEffect } from "react";
|
||||
export const ModalInfoWhyCantCreate = () => {
|
||||
const { whyCantCreatePublic, openModalInfoWhyCantCreate } = useUiTools();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
console.log(whyCantCreatePublic)
|
||||
if (Object.values(whyCantCreatePublic).length===0) {
|
||||
console.log("нет проблем")
|
||||
updateModalInfoWhyCantCreate(false)
|
||||
}
|
||||
}, [openModalInfoWhyCantCreate])
|
||||
|
||||
return (
|
||||
<Modal open={openModalInfoWhyCantCreate} onClose={() => updateModalInfoWhyCantCreate(false)}>
|
||||
<Box
|
||||
@ -30,7 +38,7 @@ export const ModalInfoWhyCantCreate = () => {
|
||||
{Object.values(whyCantCreatePublic).map((data) => {
|
||||
return (
|
||||
<Box>
|
||||
<Typography color="#7e2aea">У вопроса "{data.name}"</Typography>
|
||||
<Typography color="#7e2aea">{data.name === "quiz" ? "У квиза" : `У вопроса "${data.name}"`}</Typography>
|
||||
{data.problems.map((problem) => (
|
||||
<Typography p="5px 0">{problem}</Typography>
|
||||
))}
|
||||
|
@ -285,7 +285,7 @@ export default function StartPageSettings() {
|
||||
Изображение
|
||||
</Typography>
|
||||
<DropZone
|
||||
text={"5 MB максимум"}
|
||||
value={"5 MB максимум"}
|
||||
sx={{ maxWidth: "300px" }}
|
||||
imageUrl={quiz.config.startpage.background.desktop}
|
||||
originalImageUrl={quiz.config.startpage.background.originalDesktop}
|
||||
@ -320,7 +320,7 @@ export default function StartPageSettings() {
|
||||
>
|
||||
<CustomTextField
|
||||
placeholder="URL видео"
|
||||
text={quiz.config.startpage.background.video ?? ""}
|
||||
value={quiz.config.startpage.background.video ?? ""}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.config.startpage.background.video = e.target.value;
|
||||
@ -396,7 +396,7 @@ export default function StartPageSettings() {
|
||||
Логотип
|
||||
</Typography>
|
||||
<DropZone
|
||||
text={"5 MB максимум"}
|
||||
value={"5 MB максимум"}
|
||||
sx={{ maxWidth: "300px" }}
|
||||
imageUrl={quiz.config.startpage.logo}
|
||||
originalImageUrl={quiz.config.startpage.originalLogo}
|
||||
@ -460,7 +460,7 @@ export default function StartPageSettings() {
|
||||
Логотип
|
||||
</Typography>
|
||||
<DropZone
|
||||
text={"5 MB максимум"}
|
||||
value={"5 MB максимум"}
|
||||
sx={{ maxWidth: "300px" }}
|
||||
imageUrl={quiz.config.startpage.logo}
|
||||
originalImageUrl={quiz.config.startpage.originalLogo}
|
||||
@ -509,7 +509,7 @@ export default function StartPageSettings() {
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
placeholder="Имя заголовка об опроснике для подбора табуретки"
|
||||
text={quiz.name}
|
||||
value={quiz.name}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.name = e.target.value;
|
||||
@ -529,7 +529,7 @@ export default function StartPageSettings() {
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
placeholder="Внимательно заполняйте поля ответов"
|
||||
text={quiz.config.startpage.description}
|
||||
value={quiz.config.startpage.description}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.config.startpage.description = e.target.value;
|
||||
@ -549,7 +549,7 @@ export default function StartPageSettings() {
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
placeholder="Начать опрос"
|
||||
text={quiz.config.startpage.button}
|
||||
value={quiz.config.startpage.button}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.config.startpage.button = e.target.value;
|
||||
@ -569,7 +569,8 @@ export default function StartPageSettings() {
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
placeholder="8-800-000-00-00"
|
||||
text={quiz.config.info.phonenumber}
|
||||
type="number"
|
||||
value={quiz.config.info.phonenumber}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.config.info.phonenumber = e.target.value;
|
||||
@ -599,7 +600,7 @@ export default function StartPageSettings() {
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
placeholder="Только лучшее"
|
||||
text={quiz.config.info.orgname}
|
||||
value={quiz.config.info.orgname}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.config.info.orgname = e.target.value;
|
||||
@ -619,7 +620,7 @@ export default function StartPageSettings() {
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
placeholder="https://mysite.com"
|
||||
text={quiz.config.info.site}
|
||||
value={quiz.config.info.site}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.config.info.site = e.target.value;
|
||||
@ -639,7 +640,7 @@ export default function StartPageSettings() {
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
placeholder="Данные наших документов"
|
||||
text={quiz.config.info.law}
|
||||
value={quiz.config.info.law}
|
||||
onChange={(e) =>
|
||||
updateQuiz(quiz.id, (quiz) => {
|
||||
quiz.config.info.law = e.target.value;
|
||||
|
@ -16,6 +16,7 @@ import { QuestionsStore, useQuestionsStore } from "./store";
|
||||
import { useUiTools } from "../uiTools/store";
|
||||
import { withErrorBoundary } from "react-error-boundary";
|
||||
import { QuizQuestionResult } from "@model/questionTypes/result";
|
||||
import { replaceEmptyLinesToSpace } from "../../utils/replaceEmptyLinesToSpace";
|
||||
|
||||
|
||||
export const setQuestions = (questions: RawQuestion[] | null) => setProducedState(state => {
|
||||
@ -202,7 +203,7 @@ export const updateQuestion = async <T = AnyTypedQuizQuestion>(
|
||||
if (q.type === null) throw new Error("Cannot send update request for untyped question");
|
||||
|
||||
try {
|
||||
const response = await questionApi.edit(questionToEditQuestionRequest(q));
|
||||
const response = await questionApi.edit(questionToEditQuestionRequest(replaceEmptyLinesToSpace(q)));
|
||||
|
||||
//Если мы делаем листочек веточкой - удаляем созданный к нему результ
|
||||
const questionResult = useQuestionsStore.getState().questions.find(questionResult => questionResult.type === "result" && questionResult.content.rule.parentId === q.content.id);
|
||||
@ -488,7 +489,6 @@ export const clearRuleForAll = () => {
|
||||
|| question.content.rule.default.length > 0
|
||||
|| question.content.rule.parentId.length > 0)
|
||||
&& question.type !== "result") {
|
||||
console.log("вызываю очистку рул вопросов")
|
||||
updateQuestion(question.content.id, question => {
|
||||
question.content.rule.parentId = "";
|
||||
question.content.rule.main = [];
|
||||
@ -510,8 +510,6 @@ export const createResult = async (
|
||||
//Мы получили запрос на создание резулта. Анализируем существует ли такой. Если да - просто делаем его активным
|
||||
const question = useQuestionsStore.getState().questions.find(q => q.type !== null && q?.content.rule.parentId === parentContentId)
|
||||
|
||||
console.log("Получил запрос на создание результа родителю ", parentContentId)
|
||||
console.log("Ищу такой же результ в списке ", question)
|
||||
if (question) {//существует, делаем активным
|
||||
|
||||
updateQuestion(question.id, (q) => {
|
||||
@ -539,6 +537,7 @@ export const createResult = async (
|
||||
type: "createBackResult",
|
||||
createdQuestion,
|
||||
});
|
||||
return createdQuestion
|
||||
} catch (error) {
|
||||
devlog("Error creating question", error);
|
||||
enqueueSnackbar("Не удалось создать вопрос");
|
||||
|
@ -21,6 +21,7 @@ interface CustomTextFieldProps {
|
||||
maxLength?: number;
|
||||
sx?: SxProps<Theme>;
|
||||
InputProps?: Partial<InputProps>;
|
||||
type?:string
|
||||
}
|
||||
|
||||
export default function CustomTextField({
|
||||
@ -35,6 +36,7 @@ export default function CustomTextField({
|
||||
emptyError,
|
||||
InputProps,
|
||||
maxLength = 200,
|
||||
type=""
|
||||
}: CustomTextFieldProps) {
|
||||
const theme = useTheme();
|
||||
|
||||
@ -47,7 +49,13 @@ export default function CustomTextField({
|
||||
|
||||
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const inputValue = event.target.value;
|
||||
setInputValue(inputValue);
|
||||
|
||||
if (type === "number" ) {
|
||||
setInputValue(inputValue .replace (/\D/g, ''));
|
||||
} else {
|
||||
setInputValue(inputValue);
|
||||
}
|
||||
|
||||
|
||||
if (onChange) {
|
||||
onChange(event);
|
||||
|
@ -38,7 +38,7 @@ export default function QuizPreviewLayout() {
|
||||
const questions = useQuestionsStore((state) => state.questions);
|
||||
const currentQuizStep = useQuizPreviewStore((state) => state.currentQuestionIndex);
|
||||
|
||||
const nonDeletedQuizQuestions = questions.filter((question) => !question.deleted);
|
||||
const nonDeletedQuizQuestions = questions.filter((question) => !question.deleted && question.type !== "result" );
|
||||
const maxCurrentQuizStep = nonDeletedQuizQuestions.length > 0 ? nonDeletedQuizQuestions.length - 1 : 0;
|
||||
const currentProgress = Math.floor((currentQuizStep / maxCurrentQuizStep) * 100);
|
||||
|
||||
@ -135,7 +135,7 @@ export default function QuizPreviewLayout() {
|
||||
}}
|
||||
IconComponent={(props) => <ArrowDownIcon {...props} />}
|
||||
>
|
||||
{Object.values(questions).map(({ id, title }, index) => (
|
||||
{Object.values(questions.filter(q=>q.type!=="result")).map(({ id, title }, index) => (
|
||||
<MenuItem
|
||||
key={id}
|
||||
value={index}
|
||||
|
@ -8,7 +8,6 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function Page({ question }: Props) {
|
||||
console.log(question);
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { AnyTypedQuizQuestion, QuestionBranchingRuleMain } from "@model/questionTypes/shared";
|
||||
import { WhyCantCreatePublic } from "@root/uiTools/store";
|
||||
import { getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
||||
import { Quiz } from "@model/quiz/quiz";
|
||||
|
||||
export const checkQuestionHint = (questions: AnyTypedQuizQuestion): Record<string, WhyCantCreatePublic> => {
|
||||
export const checkQuestionHint = (questions: AnyTypedQuizQuestion, quiz:Quiz): Record<string, WhyCantCreatePublic> => {
|
||||
|
||||
const problems: any = {}
|
||||
|
||||
if (quiz.config.startpageType === null) problems.quiz = {name: "quiz", problems: ["Не выбран тип стартовой страницы"]}
|
||||
|
||||
const pushProblem = (id: string, problem: string, title: string) => {
|
||||
//Если первый вопрос с проблемой - создаём запись. Если не первый - добавляем проблему
|
||||
if (id in problems) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
||||
import { clearRuleForAll, deleteQuestion, getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
||||
import { clearRuleForAll, createResult, deleteQuestion, getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
||||
import { updateRootContentId } from "@root/quizes/actions";
|
||||
|
||||
//Всё здесь нужно сделать последовательно. И пусть весь мир ждёт.
|
||||
@ -11,11 +11,13 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) =
|
||||
if (question.content.rule.parentId === "root") { //удалить из стора root и очистить rule всем вопросам
|
||||
updateRootContentId(quiz.id, "");
|
||||
await clearRuleForAll();
|
||||
console.log("очистка рулов закончилась")
|
||||
await deleteQuestion(question.id);
|
||||
} else if (question.content.rule.parentId.length > 0) { //удалить из стора вопрос из дерева и очистить его потомков
|
||||
const clearQuestions = [] as string[];
|
||||
|
||||
const parentQuestion = getQuestionByContentId(question.content.rule.parentId);
|
||||
let startCountParentChildren = parentQuestion.content.rule.children
|
||||
|
||||
//записываем потомков , а их результаты удаляем
|
||||
const getChildren = (parentQuestion: AnyTypedQuizQuestion) => {
|
||||
questions.forEach((targetQuestion) => {
|
||||
@ -41,18 +43,54 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) =
|
||||
)
|
||||
|
||||
|
||||
|
||||
//чистим rule родителя
|
||||
const parentQuestion = getQuestionByContentId(question.content.rule.parentId);
|
||||
const newRule = {};
|
||||
const parentChildren = [...parentQuestion.content.rule.children];
|
||||
|
||||
|
||||
|
||||
console.log("_________________УДАЛЯЕМЫЙ ВОПРОС_________________", question.content.id)
|
||||
console.log(parentChildren)
|
||||
console.log(question.content.id)
|
||||
console.log(parentChildren.includes(question.content.id))
|
||||
|
||||
|
||||
if (parentChildren.includes(question.content.id))
|
||||
parentChildren.splice(parentQuestion.content.rule.children.indexOf(question.content.id), 1)
|
||||
|
||||
console.log("получившийся массив ", parentChildren)
|
||||
newRule.main = parentQuestion.content.rule.main.filter((data) => data.next !== question.content.id); //удаляем условия перехода от родителя к этому вопросу
|
||||
newRule.parentId = parentQuestion.content.rule.parentId;
|
||||
newRule.default = parentQuestion.content.rule.parentId === question.content.id ? "" : parentQuestion.content.rule.parentId;
|
||||
newRule.children = [...parentQuestion.content.rule.children].splice(parentQuestion.content.rule.children.indexOf(question.content.id), 1);
|
||||
newRule.children = parentChildren
|
||||
|
||||
await updateQuestion(question.content.rule.parentId, (PQ) => {
|
||||
PQ.content.rule = newRule;
|
||||
});
|
||||
await deleteQuestion(question.id);
|
||||
|
||||
const parentResult = questions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestion.content.id)
|
||||
|
||||
|
||||
|
||||
//сделать результ родителя видимым если у него не осталось потомков
|
||||
console.log("пришло время анализировать сделать ли результат родителя видимым")
|
||||
console.log("количество детей ", startCountParentChildren.length)
|
||||
|
||||
|
||||
if (startCountParentChildren.length === 1) {
|
||||
if (parentResult) {
|
||||
console.log("я нашел результат родителя")
|
||||
await updateQuestion(parentResult.content.id, q => {
|
||||
q.content.usage = true
|
||||
})
|
||||
} else { //почему-то не существует результа у родителя. Создаём. Новосозданные результы видны сразу
|
||||
console.log("я не нашел результат родителя")
|
||||
await createResult(quiz.backendId, parentQuestion.content.id)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await deleteQuestion(question.id);
|
||||
@ -60,8 +98,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);
|
||||
}
|
||||
|
||||
}
|
@ -6,12 +6,10 @@ import { DeleteFunction } from "@utils/deleteFunc";
|
||||
type allQuestionsTypes = AnyTypedQuizQuestion | UntypedQuizQuestion
|
||||
|
||||
export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], quiz: Quiz|undefined) => {
|
||||
console.log("Я отвечаю за удаление неудалёнышей при переключении. Привет, буде знакомы")
|
||||
const questionsForDeletion = questions.filter(
|
||||
({ type, deleted }) => type && type !== "result" && deleted
|
||||
) as AnyTypedQuizQuestion[];
|
||||
if (questionsForDeletion.length > 0) {
|
||||
console.log("меняю занятость беком на true")
|
||||
updateSomeWorkBackend(true)
|
||||
|
||||
|
||||
@ -19,7 +17,6 @@ export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], q
|
||||
questionsForDeletion.map(question => DeleteFunction(questions, question, quiz))
|
||||
)
|
||||
|
||||
console.log("______________меняю на 'можно редактировать дальше'______________")
|
||||
updateSomeWorkBackend(false)
|
||||
}
|
||||
};
|
@ -6,11 +6,11 @@ export const useAddAnswer = () => {
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const onClickAddAnAnswer = (question: QuizQuestionsWithVariants) => {
|
||||
if (question.content.variants.length >= 10) {
|
||||
enqueueSnackbar("100 максимальное количество вопросов");
|
||||
} else {
|
||||
// if (question.content.variants.length >= 10) {
|
||||
// enqueueSnackbar("100 максимальное количество вопросов");
|
||||
// } else {
|
||||
addQuestionVariant(question.id);
|
||||
}
|
||||
// }
|
||||
};
|
||||
|
||||
return onClickAddAnAnswer;
|
||||
|
33
src/utils/replaceEmptyLinesToSpace.ts
Normal file
33
src/utils/replaceEmptyLinesToSpace.ts
Normal file
@ -0,0 +1,33 @@
|
||||
export const replaceEmptyLinesToSpace = <T = unknown>(object: T): T => {
|
||||
if (Array.isArray(object)) {
|
||||
return object.map(replaceEmptyLinesToSpace) as T;
|
||||
}
|
||||
|
||||
if (!object || typeof object !== "object") {
|
||||
return object;
|
||||
}
|
||||
|
||||
const result: Record<string, unknown> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
if (typeof value === "string") {
|
||||
if (value === "") {
|
||||
result[key] = " ";
|
||||
} else {
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof value === "object") {
|
||||
result[key] = replaceEmptyLinesToSpace(value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
return result as T;
|
||||
};
|
29
src/utils/replaceSpacesToEmptyLines.ts
Normal file
29
src/utils/replaceSpacesToEmptyLines.ts
Normal file
@ -0,0 +1,29 @@
|
||||
export const replaceSpacesToEmptyLines = <T = unknown>(object: T): T => {
|
||||
if (Array.isArray(object)) {
|
||||
return object.map(replaceSpacesToEmptyLines) as T;
|
||||
}
|
||||
|
||||
if (!object || typeof object !== "object") {
|
||||
return object;
|
||||
}
|
||||
|
||||
const result: Record<string, unknown> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
if (typeof value === "string") {
|
||||
result[key] = value.replace(/ /g, "");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof value === "object") {
|
||||
result[key] = replaceSpacesToEmptyLines(value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
return result as T;
|
||||
};
|
Loading…
Reference in New Issue
Block a user