Merge branch 'fixes' into dev
This commit is contained in:
commit
6316a95340
@ -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,22 +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);
|
||||||
|
|
||||||
|
|||||||
@ -221,7 +221,7 @@ export const Footer = ({
|
|||||||
const questionIndex = questions.findIndex(({ id }) => id === question.id);
|
const questionIndex = questions.findIndex(({ id }) => id === question.id);
|
||||||
|
|
||||||
const previousQuestion = questions[questionIndex - 1];
|
const previousQuestion = questions[questionIndex - 1];
|
||||||
|
followPreviousStep
|
||||||
if (previousQuestion) {
|
if (previousQuestion) {
|
||||||
setCurrentQuestion(previousQuestion);
|
setCurrentQuestion(previousQuestion);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,14 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Box, Button, ThemeProvider, useTheme } from "@mui/material";
|
import { Box, ThemeProvider, useTheme } from "@mui/material";
|
||||||
|
|
||||||
import { StartPageViewPublication } from "./StartPageViewPublication";
|
import { StartPageViewPublication } from "./StartPageViewPublication";
|
||||||
import { Question } from "./Question";
|
import { Question } from "./Question";
|
||||||
import { useQuestions } from "@root/questions/hooks";
|
|
||||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||||
import useSWR from "swr";
|
|
||||||
import { quizApi } from "@api/quiz";
|
import { quizApi } from "@api/quiz";
|
||||||
import { setQuizes, updateQuiz } from "@root/quizes/actions";
|
import { setQuizes, updateQuiz } from "@root/quizes/actions";
|
||||||
import { isAxiosError } from "axios";
|
|
||||||
import { devlog } from "@frontend/kitui";
|
|
||||||
import { useQuizStore } from "@root/quizes/store";
|
import { useQuizStore } from "@root/quizes/store";
|
||||||
|
|
||||||
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
||||||
import { enqueueSnackbar } from "notistack";
|
|
||||||
import { useQuestionsStore } from "@root/questions/store";
|
import { useQuestionsStore } from "@root/questions/store";
|
||||||
import { setQuestions } from "@root/questions/actions";
|
import { setQuestions } from "@root/questions/actions";
|
||||||
import { questionApi } from "@api/question";
|
import { questionApi } from "@api/question";
|
||||||
|
|||||||
@ -122,7 +122,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
|||||||
onChange={({ target }) => {
|
onChange={({ target }) => {
|
||||||
updateAnswer(
|
updateAnswer(
|
||||||
currentQuestion.content.id,
|
currentQuestion.content.id,
|
||||||
window.Number(target.value) > max
|
window.Number(target.value.replace (/\D/, '')) > max
|
||||||
? String(max)
|
? String(max)
|
||||||
: window.Number(target.value) < min
|
: window.Number(target.value) < min
|
||||||
? String(min)
|
? String(min)
|
||||||
@ -155,7 +155,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
|||||||
placeholder="0"
|
placeholder="0"
|
||||||
value={minRange}
|
value={minRange}
|
||||||
onChange={({ target }) => {
|
onChange={({ target }) => {
|
||||||
setMinRange(target.value);
|
setMinRange(target.value.replace (/\D/, ''));
|
||||||
|
|
||||||
if (window.Number(target.value) >= window.Number(maxRange)) {
|
if (window.Number(target.value) >= window.Number(maxRange)) {
|
||||||
updateMinRangeDebounced(`${maxRange}—${maxRange}`, true);
|
updateMinRangeDebounced(`${maxRange}—${maxRange}`, true);
|
||||||
@ -181,7 +181,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
|||||||
placeholder="0"
|
placeholder="0"
|
||||||
value={maxRange}
|
value={maxRange}
|
||||||
onChange={({ target }) => {
|
onChange={({ target }) => {
|
||||||
setMaxRange(target.value);
|
setMaxRange(target.value.replace (/\D/, ''));
|
||||||
|
|
||||||
if (window.Number(target.value) <= window.Number(minRange)) {
|
if (window.Number(target.value) <= window.Number(minRange)) {
|
||||||
updateMaxRangeDebounced(`${minRange}—${minRange}`, true);
|
updateMaxRangeDebounced(`${minRange}—${minRange}`, true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user