Merge branch 'dev' into 'main'
Dev See merge request frontend/squiz!113
This commit is contained in:
commit
b8b80a93d3
@ -10,6 +10,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
collapseAllQuestions,
|
collapseAllQuestions,
|
||||||
createUntypedQuestion,
|
createUntypedQuestion,
|
||||||
|
setQuestions,
|
||||||
} from "@root/questions/actions";
|
} from "@root/questions/actions";
|
||||||
import {
|
import {
|
||||||
decrementCurrentStep,
|
decrementCurrentStep,
|
||||||
@ -25,6 +26,8 @@ import { QuestionSwitchWindowTool } from "./QuestionSwitchWindowTool";
|
|||||||
import { useQuestionsStore } from "@root/questions/store";
|
import { useQuestionsStore } from "@root/questions/store";
|
||||||
import { updateEditSomeQuestion } from "@root/uiTools/actions";
|
import { updateEditSomeQuestion } from "@root/uiTools/actions";
|
||||||
import { useUiTools } from "@root/uiTools/store";
|
import { useUiTools } from "@root/uiTools/store";
|
||||||
|
import { questionApi } from "@api/question";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
openBranchingPage: boolean;
|
openBranchingPage: boolean;
|
||||||
@ -39,6 +42,8 @@ export default function QuestionsPage({
|
|||||||
const { openedModalSettingsId } = useUiTools();
|
const { openedModalSettingsId } = useUiTools();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const { questions } = useQuestionsStore();
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
updateEditSomeQuestion();
|
updateEditSomeQuestion();
|
||||||
}, []);
|
}, []);
|
||||||
@ -46,6 +51,8 @@ export default function QuestionsPage({
|
|||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
if (!quiz) return null;
|
if (!quiz) return null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@ -18,17 +18,20 @@ import { ResultCard, checkEmptyData } from "./cards/ResultCard";
|
|||||||
import { EmailSettingsCard } from "./cards/EmailSettingsCard";
|
import { EmailSettingsCard } from "./cards/EmailSettingsCard";
|
||||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||||
import { useQuestionsStore } from "@root/questions/store";
|
import { useQuestionsStore } from "@root/questions/store";
|
||||||
import { createResult, deleteQuestion } from "@root/questions/actions";
|
import { createResult, deleteQuestion, setQuestions } from "@root/questions/actions";
|
||||||
import { QuizQuestionResult } from "@model/questionTypes/result";
|
import { QuizQuestionResult } from "@model/questionTypes/result";
|
||||||
|
|
||||||
import IconPlus from "@icons/IconPlus";
|
import IconPlus from "@icons/IconPlus";
|
||||||
import Info from "@icons/Info";
|
import Info from "@icons/Info";
|
||||||
import Plus from "@icons/Plus";
|
import Plus from "@icons/Plus";
|
||||||
import ArrowLeft from "@icons/questionsPage/arrowLeft";
|
import ArrowLeft from "@icons/questionsPage/arrowLeft";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { questionApi } from "@api/question";
|
||||||
|
|
||||||
export const ResultSettings = () => {
|
export const ResultSettings = () => {
|
||||||
const { questions } = useQuestionsStore();
|
const { questions } = useQuestionsStore();
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
|
const navigate = useNavigate()
|
||||||
const results = useQuestionsStore().questions.filter(
|
const results = useQuestionsStore().questions.filter(
|
||||||
(q): q is QuizQuestionResult => q.type === "result",
|
(q): q is QuizQuestionResult => q.type === "result",
|
||||||
);
|
);
|
||||||
@ -56,20 +59,6 @@ export const ResultSettings = () => {
|
|||||||
[results],
|
[results],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
//Всегда должен существовать хоть 1 резулт - "line"
|
|
||||||
if (
|
|
||||||
!questions?.find( (q) => (q.type === "result" && q.content.rule.parentId === "line"))
|
|
||||||
) {
|
|
||||||
createResult(quiz?.backendId, "line");
|
|
||||||
console.log("Я не нашёл линейный резулт и собираюсь создать новый");
|
|
||||||
}
|
|
||||||
return () => {
|
|
||||||
if (!isReadyToLeaveRef.current && window.location.pathname !== "/edit") {
|
|
||||||
setOpenNotificationModal(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const cnsl = results.filter((q) => q.content.usage);
|
const cnsl = results.filter((q) => q.content.usage);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Box, useTheme } from "@mui/material";
|
import { Box, useMediaQuery, useTheme } from "@mui/material";
|
||||||
|
|
||||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||||
import { getQuestionByContentId } from "@root/questions/actions";
|
import { getQuestionByContentId } from "@root/questions/actions";
|
||||||
@ -46,6 +46,8 @@ const QUESTIONS_MAP: any = {
|
|||||||
|
|
||||||
export const Question = ({ questions }: QuestionProps) => {
|
export const Question = ({ questions }: QuestionProps) => {
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
|
const theme = useTheme();
|
||||||
|
const isMobile = useMediaQuery(theme.breakpoints.down(650));
|
||||||
const [currentQuestion, setCurrentQuestion] =
|
const [currentQuestion, setCurrentQuestion] =
|
||||||
useState<AnyTypedQuizQuestion>();
|
useState<AnyTypedQuizQuestion>();
|
||||||
const [showContactForm, setShowContactForm] = useState<boolean>(false);
|
const [showContactForm, setShowContactForm] = useState<boolean>(false);
|
||||||
@ -67,13 +69,13 @@ export const Question = ({ questions }: QuestionProps) => {
|
|||||||
|
|
||||||
const QuestionComponent =
|
const QuestionComponent =
|
||||||
QUESTIONS_MAP[currentQuestion.type as Exclude<QuestionType, "nonselected">];
|
QUESTIONS_MAP[currentQuestion.type as Exclude<QuestionType, "nonselected">];
|
||||||
const theme = useTheme();
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: theme.palette.background.default,
|
backgroundColor: theme.palette.background.default,
|
||||||
|
height: isMobile ? undefined : "100vh",
|
||||||
}}
|
}}
|
||||||
height="100vh"
|
|
||||||
>
|
>
|
||||||
{!showContactForm && !showResultForm && (
|
{!showContactForm && !showResultForm && (
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@ -72,7 +72,7 @@ export const ResultForm = ({
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
height: "100vh",
|
height: isMobile ? undefined : "100vh",
|
||||||
width: "100vw",
|
width: "100vw",
|
||||||
pt: "28px",
|
pt: "28px",
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -505,7 +505,7 @@ function QuizPreviewLayoutByType({
|
|||||||
padding: "16px",
|
padding: "16px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
justifyContent: "center",
|
justifyContent: "space-between",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
"&::-webkit-scrollbar": { width: 0 },
|
"&::-webkit-scrollbar": { width: 0 },
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export type UiTools = {
|
|||||||
deleteNodeId: string | null;
|
deleteNodeId: string | null;
|
||||||
showConfirmLeaveModal: boolean;
|
showConfirmLeaveModal: boolean;
|
||||||
someWorkBackend: boolean;
|
someWorkBackend: boolean;
|
||||||
nextStep: number
|
nextStep: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WhyCantCreatePublic = {
|
export type WhyCantCreatePublic = {
|
||||||
@ -31,7 +31,7 @@ const initialState: UiTools = {
|
|||||||
deleteNodeId: null,
|
deleteNodeId: null,
|
||||||
showConfirmLeaveModal: false,
|
showConfirmLeaveModal: false,
|
||||||
someWorkBackend: false,
|
someWorkBackend: false,
|
||||||
nextStep: -1
|
nextStep: -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useUiTools = create<UiTools>()(
|
export const useUiTools = create<UiTools>()(
|
||||||
|
|||||||
@ -173,7 +173,8 @@ export const CropModal: FC<Props> = ({
|
|||||||
height: isMobile ? "80vh" : undefined,
|
height: isMobile ? "80vh" : undefined,
|
||||||
display: isMobile ? "flex" : undefined,
|
display: isMobile ? "flex" : undefined,
|
||||||
flexDirection: isMobile ? "column" : undefined,
|
flexDirection: isMobile ? "column" : undefined,
|
||||||
justifyContent: isMobile ? "space-evenly" : undefined,
|
justifyContent: isMobile ? "flex-start" : undefined,
|
||||||
|
overflow: isMobile ? "auto" : undefined,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@ -38,7 +38,7 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
navigate("/edit");
|
navigate("/edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNextStep(index)
|
updateNextStep(index);
|
||||||
changePage(index);
|
changePage(index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user