стр результатов проверяет наличие линейного резулта + выход со стр резултов кидает на правильное меню
This commit is contained in:
parent
6b5bf705c6
commit
3e86ef34b1
@ -18,7 +18,7 @@ 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 { deleteQuestion } from "@root/questions/actions";
|
import { createResult, deleteQuestion } 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";
|
||||||
@ -57,6 +57,13 @@ export const ResultSettings = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
//Всегда должен существовать хоть 1 резулт - "line"
|
||||||
|
if (
|
||||||
|
!questions?.find( (q) => (q.type === "result" && q.content.rule.parentId === "line"))
|
||||||
|
) {
|
||||||
|
createResult(quiz?.backendId, "line");
|
||||||
|
console.log("Я не нашёл линейный резулт и собираюсь создать новый");
|
||||||
|
}
|
||||||
return () => {
|
return () => {
|
||||||
if (!isReadyToLeaveRef.current && window.location.pathname !== "/edit") {
|
if (!isReadyToLeaveRef.current && window.location.pathname !== "/edit") {
|
||||||
setOpenNotificationModal(true);
|
setOpenNotificationModal(true);
|
||||||
|
@ -54,13 +54,12 @@ export default function EditPage({
|
|||||||
const { editQuizId } = useQuizStore();
|
const { editQuizId } = useQuizStore();
|
||||||
const { questions } = useQuestionsStore();
|
const { questions } = useQuestionsStore();
|
||||||
console.log(questions);
|
console.log(questions);
|
||||||
const { whyCantCreatePublic, showConfirmLeaveModal } = useUiTools();
|
const { whyCantCreatePublic, showConfirmLeaveModal, nextStep } = useUiTools();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const currentStep = useQuizStore((state) => state.currentStep);
|
const currentStep = useQuizStore((state) => state.currentStep);
|
||||||
const isBranchingLogic = useMediaQuery(theme.breakpoints.down(1100));
|
const isBranchingLogic = useMediaQuery(theme.breakpoints.down(1100));
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
||||||
const [nextStep, setNextStep] = useState<number>(0);
|
|
||||||
const quizConfig = quiz?.config;
|
const quizConfig = quiz?.config;
|
||||||
// const [openBranchingPage, setOpenBranchingPage] = useState<boolean>(false);
|
// const [openBranchingPage, setOpenBranchingPage] = useState<boolean>(false);
|
||||||
|
|
||||||
|
@ -40,3 +40,6 @@ export const setShowConfirmLeaveModal = (showConfirmLeaveModal: boolean) =>
|
|||||||
|
|
||||||
export const updateSomeWorkBackend = (someWorkBackend: boolean) =>
|
export const updateSomeWorkBackend = (someWorkBackend: boolean) =>
|
||||||
useUiTools.setState({ someWorkBackend });
|
useUiTools.setState({ someWorkBackend });
|
||||||
|
|
||||||
|
export const updateNextStep = (nextStep: number) =>
|
||||||
|
useUiTools.setState({ nextStep });
|
||||||
|
@ -12,6 +12,7 @@ export type UiTools = {
|
|||||||
deleteNodeId: string | null;
|
deleteNodeId: string | null;
|
||||||
showConfirmLeaveModal: boolean;
|
showConfirmLeaveModal: boolean;
|
||||||
someWorkBackend: boolean;
|
someWorkBackend: boolean;
|
||||||
|
nextStep: number
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WhyCantCreatePublic = {
|
export type WhyCantCreatePublic = {
|
||||||
@ -30,6 +31,7 @@ const initialState: UiTools = {
|
|||||||
deleteNodeId: null,
|
deleteNodeId: null,
|
||||||
showConfirmLeaveModal: false,
|
showConfirmLeaveModal: false,
|
||||||
someWorkBackend: false,
|
someWorkBackend: false,
|
||||||
|
nextStep: -1
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useUiTools = create<UiTools>()(
|
export const useUiTools = create<UiTools>()(
|
||||||
|
@ -11,6 +11,7 @@ import MenuItem from "../MenuItem";
|
|||||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import { setCurrentStep } from "@root/quizes/actions";
|
import { setCurrentStep } from "@root/quizes/actions";
|
||||||
|
import { updateNextStep } from "@root/uiTools/actions";
|
||||||
|
|
||||||
const quizSettingsMenuItems = [
|
const quizSettingsMenuItems = [
|
||||||
[TagIcon, "Дополнения"],
|
[TagIcon, "Дополнения"],
|
||||||
@ -37,6 +38,7 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
navigate("/edit");
|
navigate("/edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateNextStep(index)
|
||||||
changePage(index);
|
changePage(index);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -106,9 +108,9 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
key={index}
|
key={index}
|
||||||
text={menuItem.sidebarText}
|
text={menuItem.sidebarText}
|
||||||
isCollapsed={isMenuCollapsed}
|
isCollapsed={isMenuCollapsed}
|
||||||
isActive={currentStep === index}
|
isActive={currentStep === index && pathname.startsWith("/edit")}
|
||||||
disabled={
|
disabled={
|
||||||
index === 0
|
pathname.startsWith("/edit")
|
||||||
? false
|
? false
|
||||||
: quiz === undefined
|
: quiz === undefined
|
||||||
? true
|
? true
|
||||||
@ -117,7 +119,7 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
icon={
|
icon={
|
||||||
<Icon
|
<Icon
|
||||||
color={
|
color={
|
||||||
currentStep === index
|
currentStep === index && pathname.startsWith("/edit")
|
||||||
? theme.palette.brightPurple.main
|
? theme.palette.brightPurple.main
|
||||||
: isMenuCollapsed
|
: isMenuCollapsed
|
||||||
? "white"
|
? "white"
|
||||||
@ -154,9 +156,9 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
}}
|
}}
|
||||||
text={"Дизайн"}
|
text={"Дизайн"}
|
||||||
isCollapsed={isMenuCollapsed}
|
isCollapsed={isMenuCollapsed}
|
||||||
isActive={currentStep === 6}
|
isActive={pathname.startsWith("/design")}
|
||||||
disabled={
|
disabled={
|
||||||
currentStep === 6
|
pathname.startsWith("/design")
|
||||||
? false
|
? false
|
||||||
: quiz === undefined
|
: quiz === undefined
|
||||||
? true
|
? true
|
||||||
@ -165,7 +167,7 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
icon={
|
icon={
|
||||||
<PencilCircleIcon
|
<PencilCircleIcon
|
||||||
color={
|
color={
|
||||||
currentStep === 6
|
pathname.startsWith("/design")
|
||||||
? theme.palette.brightPurple.main
|
? theme.palette.brightPurple.main
|
||||||
: isMenuCollapsed
|
: isMenuCollapsed
|
||||||
? "white"
|
? "white"
|
||||||
|
Loading…
Reference in New Issue
Block a user