Merge branch 'fixes' into dev
This commit is contained in:
commit
6316a95340
@ -10,6 +10,7 @@ import {
|
||||
import {
|
||||
collapseAllQuestions,
|
||||
createUntypedQuestion,
|
||||
setQuestions,
|
||||
} from "@root/questions/actions";
|
||||
import {
|
||||
decrementCurrentStep,
|
||||
@ -25,6 +26,8 @@ import { QuestionSwitchWindowTool } from "./QuestionSwitchWindowTool";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
import { updateEditSomeQuestion } from "@root/uiTools/actions";
|
||||
import { useUiTools } from "@root/uiTools/store";
|
||||
import { questionApi } from "@api/question";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
interface Props {
|
||||
openBranchingPage: boolean;
|
||||
@ -39,6 +42,8 @@ export default function QuestionsPage({
|
||||
const { openedModalSettingsId } = useUiTools();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
||||
const quiz = useCurrentQuiz();
|
||||
const navigate = useNavigate()
|
||||
const { questions } = useQuestionsStore();
|
||||
useLayoutEffect(() => {
|
||||
updateEditSomeQuestion();
|
||||
}, []);
|
||||
@ -46,6 +51,8 @@ export default function QuestionsPage({
|
||||
const ref = useRef();
|
||||
if (!quiz) return null;
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
|
||||
@ -18,17 +18,20 @@ import { ResultCard, checkEmptyData } from "./cards/ResultCard";
|
||||
import { EmailSettingsCard } from "./cards/EmailSettingsCard";
|
||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
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 IconPlus from "@icons/IconPlus";
|
||||
import Info from "@icons/Info";
|
||||
import Plus from "@icons/Plus";
|
||||
import ArrowLeft from "@icons/questionsPage/arrowLeft";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { questionApi } from "@api/question";
|
||||
|
||||
export const ResultSettings = () => {
|
||||
const { questions } = useQuestionsStore();
|
||||
const quiz = useCurrentQuiz();
|
||||
const navigate = useNavigate()
|
||||
const results = useQuestionsStore().questions.filter(
|
||||
(q): q is QuizQuestionResult => q.type === "result",
|
||||
);
|
||||
@ -56,22 +59,6 @@ export const ResultSettings = () => {
|
||||
[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);
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ export const Footer = ({
|
||||
const questionIndex = questions.findIndex(({ id }) => id === question.id);
|
||||
|
||||
const previousQuestion = questions[questionIndex - 1];
|
||||
|
||||
followPreviousStep
|
||||
if (previousQuestion) {
|
||||
setCurrentQuestion(previousQuestion);
|
||||
}
|
||||
|
||||
@ -1,19 +1,14 @@
|
||||
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 { Question } from "./Question";
|
||||
import { useQuestions } from "@root/questions/hooks";
|
||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
import useSWR from "swr";
|
||||
import { quizApi } from "@api/quiz";
|
||||
import { setQuizes, updateQuiz } from "@root/quizes/actions";
|
||||
import { isAxiosError } from "axios";
|
||||
import { devlog } from "@frontend/kitui";
|
||||
import { useQuizStore } from "@root/quizes/store";
|
||||
|
||||
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
import { setQuestions } from "@root/questions/actions";
|
||||
import { questionApi } from "@api/question";
|
||||
|
||||
@ -122,7 +122,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
||||
onChange={({ target }) => {
|
||||
updateAnswer(
|
||||
currentQuestion.content.id,
|
||||
window.Number(target.value) > max
|
||||
window.Number(target.value.replace (/\D/, '')) > max
|
||||
? String(max)
|
||||
: window.Number(target.value) < min
|
||||
? String(min)
|
||||
@ -155,7 +155,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
||||
placeholder="0"
|
||||
value={minRange}
|
||||
onChange={({ target }) => {
|
||||
setMinRange(target.value);
|
||||
setMinRange(target.value.replace (/\D/, ''));
|
||||
|
||||
if (window.Number(target.value) >= window.Number(maxRange)) {
|
||||
updateMinRangeDebounced(`${maxRange}—${maxRange}`, true);
|
||||
@ -181,7 +181,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
||||
placeholder="0"
|
||||
value={maxRange}
|
||||
onChange={({ target }) => {
|
||||
setMaxRange(target.value);
|
||||
setMaxRange(target.value.replace (/\D/, ''));
|
||||
|
||||
if (window.Number(target.value) <= window.Number(minRange)) {
|
||||
updateMaxRangeDebounced(`${minRange}—${minRange}`, true);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user