2023-12-13 23:34:34 +00:00
|
|
|
|
import { quizApi } from "@api/quiz";
|
2023-12-18 15:52:59 +00:00
|
|
|
|
import { LogoutButton } from "@ui_kit/LogoutButton";
|
2023-05-31 10:50:30 +00:00
|
|
|
|
import BackArrowIcon from "@icons/BackArrowIcon";
|
2023-11-13 18:04:51 +00:00
|
|
|
|
import { Burger } from "@icons/Burger";
|
2023-12-13 23:34:34 +00:00
|
|
|
|
import EyeIcon from "@icons/EyeIcon";
|
2023-11-13 18:04:51 +00:00
|
|
|
|
import { PenaLogoIcon } from "@icons/PenaLogoIcon";
|
2023-12-27 15:16:23 +00:00
|
|
|
|
import VisibilityIcon from "@mui/icons-material/Visibility";
|
|
|
|
|
|
2023-11-13 18:04:51 +00:00
|
|
|
|
import {
|
2023-12-16 23:10:24 +00:00
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
Container,
|
|
|
|
|
FormControl,
|
|
|
|
|
IconButton,
|
|
|
|
|
Switch,
|
|
|
|
|
TextField,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
2023-11-13 18:04:51 +00:00
|
|
|
|
} from "@mui/material";
|
2023-12-29 10:17:43 +00:00
|
|
|
|
import {
|
|
|
|
|
resetEditConfig,
|
|
|
|
|
setQuizes,
|
|
|
|
|
updateQuiz,
|
|
|
|
|
setCurrentStep,
|
|
|
|
|
} from "@root/quizes/actions";
|
2023-11-13 18:04:51 +00:00
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
|
|
|
|
import { useQuizStore } from "@root/quizes/store";
|
2023-05-31 10:50:30 +00:00
|
|
|
|
import CustomAvatar from "@ui_kit/Header/Avatar";
|
2023-11-13 18:04:51 +00:00
|
|
|
|
import NavMenuItem from "@ui_kit/Header/NavMenuItem";
|
|
|
|
|
import PenaLogo from "@ui_kit/PenaLogo";
|
2023-05-31 10:50:30 +00:00
|
|
|
|
import Sidebar from "@ui_kit/Sidebar";
|
2023-11-13 18:04:51 +00:00
|
|
|
|
import Stepper from "@ui_kit/Stepper";
|
|
|
|
|
import SwitchStepPages from "@ui_kit/switchStepPages";
|
2023-12-13 23:34:34 +00:00
|
|
|
|
import { isAxiosError } from "axios";
|
|
|
|
|
import { enqueueSnackbar } from "notistack";
|
2023-12-17 23:29:31 +00:00
|
|
|
|
import React, { useEffect, useLayoutEffect, useState } from "react";
|
2023-11-14 14:22:10 +00:00
|
|
|
|
import { Link, useNavigate } from "react-router-dom";
|
2023-12-13 23:34:34 +00:00
|
|
|
|
import useSWR from "swr";
|
2023-12-19 11:35:59 +00:00
|
|
|
|
import { useDebouncedCallback } from "use-debounce";
|
2023-09-21 07:00:08 +00:00
|
|
|
|
import { SidebarMobile } from "./Sidebar/SidebarMobile";
|
2023-12-29 10:17:43 +00:00
|
|
|
|
import {
|
|
|
|
|
cleanQuestions,
|
|
|
|
|
createResult,
|
|
|
|
|
setQuestions,
|
|
|
|
|
} from "@root/questions/actions";
|
2023-12-26 12:57:44 +00:00
|
|
|
|
import {
|
|
|
|
|
updateOpenBranchingPanel,
|
|
|
|
|
updateCanCreatePublic,
|
|
|
|
|
updateModalInfoWhyCantCreate,
|
|
|
|
|
setShowConfirmLeaveModal,
|
2023-12-27 21:16:48 +00:00
|
|
|
|
updateSomeWorkBackend,
|
2023-12-26 12:57:44 +00:00
|
|
|
|
} from "@root/uiTools/actions";
|
2023-12-14 09:40:53 +00:00
|
|
|
|
import { BranchingPanel } from "../Questions/BranchingPanel";
|
2023-12-29 13:32:57 +00:00
|
|
|
|
import { Header } from "./Header";
|
2023-12-14 09:40:53 +00:00
|
|
|
|
import { useQuestionsStore } from "@root/questions/store";
|
|
|
|
|
import { useQuizes } from "@root/quizes/hooks";
|
2023-12-13 23:34:34 +00:00
|
|
|
|
import { questionApi } from "@api/question";
|
2023-12-14 09:40:53 +00:00
|
|
|
|
import { useUiTools } from "@root/uiTools/store";
|
|
|
|
|
|
2023-12-16 23:10:24 +00:00
|
|
|
|
import Logotip from "../Landing/images/icons/QuizLogo";
|
2023-12-18 15:52:59 +00:00
|
|
|
|
import { clearUserData } from "@root/user";
|
|
|
|
|
import { clearAuthToken } from "@frontend/kitui";
|
|
|
|
|
import { logout } from "@api/auth";
|
2023-12-19 11:35:59 +00:00
|
|
|
|
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
2023-12-19 13:42:43 +00:00
|
|
|
|
import { ModalInfoWhyCantCreate } from "./ModalInfoWhyCantCreate";
|
2023-12-26 12:57:44 +00:00
|
|
|
|
import { ConfirmLeaveModal } from "./ConfirmLeaveModal";
|
|
|
|
|
import { checkQuestionHint } from "@utils/checkQuestionHint";
|
2023-12-27 07:25:30 +00:00
|
|
|
|
import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
|
2023-12-27 15:16:23 +00:00
|
|
|
|
import { toggleQuizPreview } from "@root/quizPreview";
|
|
|
|
|
import { LinkSimple } from "@icons/LinkSimple";
|
|
|
|
|
import { BackButtonIcon } from "@icons/BackButtonIcon";
|
2023-12-27 20:27:12 +00:00
|
|
|
|
import { TreeStructure } from "@icons/TreeStructure";
|
2023-12-13 23:34:34 +00:00
|
|
|
|
|
2023-12-27 11:48:25 +00:00
|
|
|
|
let init: () => void;
|
2023-12-07 22:56:31 +00:00
|
|
|
|
export default function EditPage() {
|
2023-12-16 23:10:24 +00:00
|
|
|
|
const quiz = useCurrentQuiz();
|
|
|
|
|
const { editQuizId } = useQuizStore();
|
2023-12-19 11:35:59 +00:00
|
|
|
|
const { questions } = useQuestionsStore();
|
2023-12-30 18:51:16 +00:00
|
|
|
|
console.log(questions)
|
2023-12-13 23:34:34 +00:00
|
|
|
|
|
2023-12-16 23:10:24 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
const quizes = await quizApi.getList();
|
|
|
|
|
setQuizes(quizes);
|
2023-12-16 04:20:07 +00:00
|
|
|
|
|
2023-12-26 12:57:44 +00:00
|
|
|
|
if (editQuizId) {
|
|
|
|
|
const questions = await questionApi.getList({ quiz_id: editQuizId });
|
2023-12-29 23:11:37 +00:00
|
|
|
|
console.log(questions)
|
2023-12-26 12:57:44 +00:00
|
|
|
|
setQuestions(questions);
|
2023-12-27 07:25:30 +00:00
|
|
|
|
//Всегда должен существовать хоть 1 резулт - "line"
|
|
|
|
|
// console.log("сейчас будем ворошиться в этих квешенах ", questions);
|
2023-12-23 00:44:57 +00:00
|
|
|
|
|
2023-12-27 07:25:30 +00:00
|
|
|
|
if (
|
|
|
|
|
!questions?.find(
|
2023-12-29 10:17:43 +00:00
|
|
|
|
(q) =>
|
|
|
|
|
(q.type === "result" && q.content.includes(':"line"')) ||
|
|
|
|
|
q.content.includes(":'line'")
|
2023-12-27 07:25:30 +00:00
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
createResult(quiz?.backendId, "line");
|
2023-12-27 11:48:25 +00:00
|
|
|
|
console.log("Я не нашёл линейный резулт и собираюсь создать новый");
|
2023-12-27 07:25:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-16 23:10:24 +00:00
|
|
|
|
};
|
|
|
|
|
getData();
|
|
|
|
|
}, []);
|
2023-12-13 23:34:34 +00:00
|
|
|
|
|
2023-12-29 10:17:43 +00:00
|
|
|
|
const {
|
|
|
|
|
openBranchingPanel,
|
|
|
|
|
whyCantCreatePublic,
|
|
|
|
|
canCreatePublic,
|
|
|
|
|
showConfirmLeaveModal,
|
|
|
|
|
} = useUiTools();
|
2023-12-16 23:10:24 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const currentStep = useQuizStore((state) => state.currentStep);
|
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
2023-12-27 21:17:39 +00:00
|
|
|
|
const isBranchingLogic = useMediaQuery(theme.breakpoints.down(1100));
|
2023-12-16 23:10:24 +00:00
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
2023-12-27 21:49:52 +00:00
|
|
|
|
const isLinkButton = useMediaQuery(theme.breakpoints.down(708));
|
2023-12-27 15:16:23 +00:00
|
|
|
|
const isMobileSm = useMediaQuery(theme.breakpoints.down(370));
|
2023-12-16 23:10:24 +00:00
|
|
|
|
const [mobileSidebar, setMobileSidebar] = useState<boolean>(false);
|
2023-12-26 12:57:44 +00:00
|
|
|
|
const [nextStep, setNextStep] = useState<number>(0);
|
2023-12-16 23:10:24 +00:00
|
|
|
|
const quizConfig = quiz?.config;
|
2023-12-26 12:57:44 +00:00
|
|
|
|
const disableTest = quiz === undefined ? true : quiz.config.type === null;
|
2023-12-27 07:25:30 +00:00
|
|
|
|
const [openBranchingPage, setOpenBranchingPage] = useState<boolean>(false);
|
2023-12-27 21:23:44 +00:00
|
|
|
|
const [buttonText, setButtonText] = useState(quiz?.status === "stop" ? "Опубликовать" : "Отозвать");
|
2023-12-27 07:25:30 +00:00
|
|
|
|
|
|
|
|
|
const openBranchingPageHC = () => {
|
|
|
|
|
if (!openBranchingPage) {
|
2023-12-27 11:48:25 +00:00
|
|
|
|
deleteTimeoutedQuestions(questions, quiz);
|
2023-12-27 07:25:30 +00:00
|
|
|
|
}
|
2023-12-27 11:48:25 +00:00
|
|
|
|
setOpenBranchingPage((old) => !old);
|
|
|
|
|
};
|
2023-03-03 23:54:19 +00:00
|
|
|
|
|
2023-12-16 23:10:24 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (editQuizId === null) navigate("/list");
|
|
|
|
|
}, [navigate, editQuizId]);
|
2023-11-14 14:22:10 +00:00
|
|
|
|
|
2023-12-16 23:10:24 +00:00
|
|
|
|
useEffect(
|
|
|
|
|
() => () => {
|
2023-12-29 14:48:53 +00:00
|
|
|
|
// resetEditConfig();
|
2023-12-16 23:10:24 +00:00
|
|
|
|
cleanQuestions();
|
2023-12-20 21:56:14 +00:00
|
|
|
|
updateModalInfoWhyCantCreate(false);
|
2023-12-29 10:17:43 +00:00
|
|
|
|
updateSomeWorkBackend(false);
|
2023-12-16 23:10:24 +00:00
|
|
|
|
},
|
|
|
|
|
[]
|
|
|
|
|
);
|
2023-12-19 11:35:59 +00:00
|
|
|
|
|
2023-12-29 10:17:43 +00:00
|
|
|
|
const updateQuestionHint = useDebouncedCallback(
|
|
|
|
|
(questions: AnyTypedQuizQuestion[]) => {
|
|
|
|
|
const problems = checkQuestionHint(questions, quiz);
|
|
|
|
|
useUiTools.setState({ whyCantCreatePublic: problems });
|
|
|
|
|
if (Object.keys(problems).length > 0) {
|
|
|
|
|
updateQuiz(quiz?.id, (state) => {
|
|
|
|
|
state.status = "stop";
|
|
|
|
|
});
|
2023-12-29 23:11:37 +00:00
|
|
|
|
setButtonText("Опубликовать")
|
2023-12-29 10:17:43 +00:00
|
|
|
|
updateCanCreatePublic(false);
|
|
|
|
|
} else {
|
|
|
|
|
updateCanCreatePublic(true);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
600
|
|
|
|
|
);
|
2023-12-19 11:35:59 +00:00
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-12-26 12:57:44 +00:00
|
|
|
|
updateQuestionHint(questions);
|
2023-12-29 23:11:37 +00:00
|
|
|
|
|
|
|
|
|
}, [questions, quiz]);
|
2023-12-21 08:29:51 +00:00
|
|
|
|
|
2023-12-26 12:57:44 +00:00
|
|
|
|
const followNewPage = () => {
|
|
|
|
|
setShowConfirmLeaveModal(false);
|
|
|
|
|
setCurrentStep(nextStep);
|
|
|
|
|
};
|
2023-11-14 14:22:10 +00:00
|
|
|
|
|
2023-12-20 21:56:14 +00:00
|
|
|
|
if (!quizConfig) return <></>;
|
2023-12-27 11:48:25 +00:00
|
|
|
|
|
2023-12-29 10:17:43 +00:00
|
|
|
|
const isConditionMet =
|
|
|
|
|
[1].includes(currentStep) &&
|
|
|
|
|
!openBranchingPanel &&
|
|
|
|
|
quizConfig.type !== "form";
|
2023-12-27 15:16:23 +00:00
|
|
|
|
|
|
|
|
|
const handleClickStatusQuiz = () => {
|
|
|
|
|
if (Object.keys(whyCantCreatePublic).length === 0) {
|
2023-12-27 15:39:21 +00:00
|
|
|
|
if (buttonText === "Опубликовать") {
|
|
|
|
|
setButtonText("Опубликовано");
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
setButtonText("Отозвать");
|
2023-12-27 21:23:44 +00:00
|
|
|
|
}, 1500);
|
2023-12-27 15:39:21 +00:00
|
|
|
|
} else {
|
|
|
|
|
setButtonText("Опубликовать");
|
|
|
|
|
}
|
2023-12-27 15:16:23 +00:00
|
|
|
|
|
|
|
|
|
updateQuiz(quiz?.id, (state) => {
|
|
|
|
|
state.status = quiz?.status === "start" ? "stop" : "start";
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
updateModalInfoWhyCantCreate(true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-29 10:17:43 +00:00
|
|
|
|
const changePage = (index: number) => {
|
|
|
|
|
if (currentStep === 2) {
|
|
|
|
|
setNextStep(index);
|
|
|
|
|
setShowConfirmLeaveModal(true);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setCurrentStep(index);
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-16 23:10:24 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-12-29 14:06:53 +00:00
|
|
|
|
<Header setMobileSidebar={setMobileSidebar} />
|
2023-12-16 23:10:24 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: isMobile ? "block" : "flex",
|
2023-12-27 20:27:12 +00:00
|
|
|
|
position: "relative",
|
2023-12-16 23:10:24 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-29 10:17:43 +00:00
|
|
|
|
{isMobile ? (
|
|
|
|
|
<SidebarMobile open={mobileSidebar} changePage={changePage} />
|
|
|
|
|
) : (
|
|
|
|
|
<Sidebar changePage={changePage} />
|
|
|
|
|
)}
|
2023-12-16 23:10:24 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
background: theme.palette.background.default,
|
|
|
|
|
width: "100%",
|
2023-12-27 15:16:23 +00:00
|
|
|
|
overflow: "hidden",
|
2023-12-16 23:10:24 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-27 11:48:25 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: isMobile ? "16px 16px 20px 16px" : "25px 25px 20px 25px",
|
|
|
|
|
overflow: "auto",
|
2023-12-29 10:17:43 +00:00
|
|
|
|
height: isMobile
|
2023-12-27 21:17:39 +00:00
|
|
|
|
? `calc(100vh - 125px)`
|
|
|
|
|
: isConditionMet
|
|
|
|
|
? isBranchingLogic
|
|
|
|
|
? `calc(100vh - 166px)`
|
|
|
|
|
: `calc(100vh - 186px)`
|
|
|
|
|
: `calc(100vh - 166px)`,
|
2023-12-27 11:48:25 +00:00
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* Выбор текущей страницы редактирования чего-либо находится здесь */}
|
|
|
|
|
{quizConfig && (
|
|
|
|
|
<>
|
|
|
|
|
<Stepper activeStep={currentStep} />
|
|
|
|
|
<SwitchStepPages
|
|
|
|
|
activeStep={currentStep}
|
|
|
|
|
quizType={quizConfig.type}
|
|
|
|
|
quizResults={quizConfig.results}
|
|
|
|
|
quizStartPageType={quizConfig.startpageType}
|
|
|
|
|
openBranchingPage={openBranchingPage}
|
|
|
|
|
setOpenBranchingPage={setOpenBranchingPage}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
padding: isMobile ? "20px 16px" : "20px 20px",
|
|
|
|
|
display: "flex",
|
2023-12-29 10:17:43 +00:00
|
|
|
|
justifyContent: isMobile
|
|
|
|
|
? isMobileSm
|
|
|
|
|
? "center"
|
|
|
|
|
: "flex-end"
|
|
|
|
|
: "flex-start",
|
2023-12-27 15:16:23 +00:00
|
|
|
|
flexDirection: isMobile ? "row-reverse" : "-moz-initial",
|
2023-12-27 11:48:25 +00:00
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "15px",
|
|
|
|
|
background: "#FFF",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-27 20:27:12 +00:00
|
|
|
|
{isConditionMet &&
|
2023-12-27 21:17:39 +00:00
|
|
|
|
(isBranchingLogic ? (
|
2023-12-27 20:27:12 +00:00
|
|
|
|
<Box
|
2023-12-26 12:57:44 +00:00
|
|
|
|
sx={{
|
2023-12-27 20:27:12 +00:00
|
|
|
|
width: "77px",
|
|
|
|
|
height: "51px",
|
|
|
|
|
position: "fixed",
|
2023-12-27 21:36:33 +00:00
|
|
|
|
zIndex: "99999",
|
2023-12-27 20:27:12 +00:00
|
|
|
|
right: "0",
|
|
|
|
|
top: "20%",
|
|
|
|
|
background: "#333647",
|
|
|
|
|
borderTopLeftRadius: "8px",
|
|
|
|
|
borderBottomLeftRadius: "8px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Switch
|
|
|
|
|
icon={<TreeStructure />}
|
|
|
|
|
checkedIcon={<TreeStructure />}
|
|
|
|
|
checked={openBranchingPage}
|
|
|
|
|
onChange={openBranchingPageHC}
|
|
|
|
|
sx={{
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 30,
|
2023-12-26 12:57:44 +00:00
|
|
|
|
padding: 0,
|
2023-12-27 20:27:12 +00:00
|
|
|
|
"& .MuiSwitch-switchBase": {
|
|
|
|
|
padding: 0,
|
|
|
|
|
margin: "2px",
|
|
|
|
|
width: "26px",
|
|
|
|
|
height: "26px",
|
|
|
|
|
background: "#fff",
|
|
|
|
|
transitionDuration: "300ms",
|
|
|
|
|
"&:hover": {
|
2023-12-27 21:41:35 +00:00
|
|
|
|
backgroundColor: "#fff !important",
|
2023-12-27 20:27:12 +00:00
|
|
|
|
},
|
|
|
|
|
"&:active": {
|
2023-12-27 20:28:19 +00:00
|
|
|
|
background: "#fff",
|
2023-12-27 20:27:12 +00:00
|
|
|
|
},
|
|
|
|
|
"&.Mui-checked": {
|
|
|
|
|
transform: "translateX(20px)",
|
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
"& + .MuiSwitch-track": {
|
|
|
|
|
backgroundColor: "#7E2AEA",
|
|
|
|
|
opacity: 1,
|
|
|
|
|
border: 0,
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled + .MuiSwitch-track": { opacity: 0.5 },
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled .MuiSwitch-thumb": {
|
|
|
|
|
color: theme.palette.mode === "light" ? theme.palette.grey[100] : theme.palette.grey[600],
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled + .MuiSwitch-track": {
|
|
|
|
|
opacity: theme.palette.mode === "light" ? 0.7 : 0.3,
|
2023-12-26 12:57:44 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
2023-12-27 20:27:12 +00:00
|
|
|
|
"& .MuiSwitch-thumb": {
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
width: 25,
|
|
|
|
|
height: 25,
|
2023-12-16 23:10:24 +00:00
|
|
|
|
},
|
2023-12-27 20:27:12 +00:00
|
|
|
|
"& .MuiSwitch-track": {
|
|
|
|
|
backgroundColor: "rgba(217, 188, 255, 0.16)",
|
|
|
|
|
borderRadius: 13,
|
|
|
|
|
opacity: 1,
|
|
|
|
|
transition: theme.transitions.create(["background-color"], {
|
2023-12-29 10:17:43 +00:00
|
|
|
|
duration: 500,
|
2023-12-27 20:27:12 +00:00
|
|
|
|
}),
|
2023-12-16 23:10:24 +00:00
|
|
|
|
},
|
2023-12-27 20:27:12 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
) : (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
2023-12-27 21:17:39 +00:00
|
|
|
|
display: "flex",
|
2023-12-27 20:27:12 +00:00
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "15px",
|
|
|
|
|
padding: "18px",
|
|
|
|
|
background: "#fff",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
boxShadow: "0px 10px 30px #e7e7e7",
|
2023-12-26 12:57:44 +00:00
|
|
|
|
}}
|
2023-12-27 20:27:12 +00:00
|
|
|
|
>
|
|
|
|
|
<Switch
|
|
|
|
|
checked={openBranchingPage}
|
|
|
|
|
onChange={openBranchingPageHC}
|
|
|
|
|
sx={{
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 30,
|
|
|
|
|
padding: 0,
|
|
|
|
|
"& .MuiSwitch-switchBase": {
|
|
|
|
|
padding: 0,
|
|
|
|
|
margin: "2px",
|
|
|
|
|
transitionDuration: "300ms",
|
|
|
|
|
"&.Mui-checked": {
|
|
|
|
|
transform: "translateX(20px)",
|
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
"& + .MuiSwitch-track": {
|
|
|
|
|
backgroundColor: "#E8DCF9",
|
|
|
|
|
opacity: 1,
|
|
|
|
|
border: 0,
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled + .MuiSwitch-track": { opacity: 0.5 },
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled .MuiSwitch-thumb": {
|
|
|
|
|
color: theme.palette.mode === "light" ? theme.palette.grey[100] : theme.palette.grey[600],
|
|
|
|
|
},
|
|
|
|
|
"&.Mui-disabled + .MuiSwitch-track": {
|
|
|
|
|
opacity: theme.palette.mode === "light" ? 0.7 : 0.3,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"& .MuiSwitch-thumb": {
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
width: 25,
|
|
|
|
|
height: 25,
|
|
|
|
|
},
|
|
|
|
|
"& .MuiSwitch-track": {
|
|
|
|
|
borderRadius: 13,
|
|
|
|
|
backgroundColor: theme.palette.mode === "light" ? "#E9E9EA" : "#39393D",
|
|
|
|
|
opacity: 1,
|
|
|
|
|
transition: theme.transitions.create(["background-color"], {
|
|
|
|
|
duration: 500,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Box>
|
2023-12-27 21:17:39 +00:00
|
|
|
|
<Typography sx={{ fontWeight: "bold", color: "#4D4D4D", whiteSpace: "nowrap" }}>
|
|
|
|
|
Логика ветвления
|
|
|
|
|
</Typography>
|
2023-12-27 20:27:12 +00:00
|
|
|
|
</Box>
|
2023-12-26 12:57:44 +00:00
|
|
|
|
</Box>
|
2023-12-27 20:27:12 +00:00
|
|
|
|
))}
|
2023-12-19 13:42:43 +00:00
|
|
|
|
|
2023-12-27 15:16:23 +00:00
|
|
|
|
<Box sx={{ display: isMobile ? "none" : "block" }}>
|
|
|
|
|
{!canCreatePublic && quiz.config.type !== "form" ? (
|
2023-12-27 11:48:25 +00:00
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
2023-12-27 15:16:23 +00:00
|
|
|
|
// disabled
|
2023-12-27 11:48:25 +00:00
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
lineHeight: "18px",
|
|
|
|
|
height: "34px",
|
2023-12-27 19:13:46 +00:00
|
|
|
|
whiteSpace: "nowrap",
|
2023-12-27 11:48:25 +00:00
|
|
|
|
minWidth: "130px",
|
|
|
|
|
}}
|
2023-12-27 15:16:23 +00:00
|
|
|
|
onClick={() =>
|
2023-12-29 10:17:43 +00:00
|
|
|
|
Object.keys(whyCantCreatePublic).length === 0
|
|
|
|
|
? () => {}
|
|
|
|
|
: updateModalInfoWhyCantCreate(true)
|
2023-12-27 15:16:23 +00:00
|
|
|
|
}
|
2023-12-27 11:48:25 +00:00
|
|
|
|
>
|
|
|
|
|
Тестовый просмотр
|
|
|
|
|
</Button>
|
2023-12-27 15:16:23 +00:00
|
|
|
|
) : (
|
2023-12-29 10:17:43 +00:00
|
|
|
|
<a
|
|
|
|
|
href={`/view`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noreferrer"
|
|
|
|
|
style={{ textDecoration: "none" }}
|
|
|
|
|
>
|
2023-12-27 15:16:23 +00:00
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "14px",
|
2023-12-27 19:13:46 +00:00
|
|
|
|
whiteSpace: "nowrap",
|
2023-12-27 15:16:23 +00:00
|
|
|
|
lineHeight: "18px",
|
|
|
|
|
height: "34px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Тестовый просмотр
|
|
|
|
|
</Button>
|
|
|
|
|
</a>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
2023-12-19 19:55:59 +00:00
|
|
|
|
|
2023-12-27 11:48:25 +00:00
|
|
|
|
<Button
|
2023-12-27 15:16:23 +00:00
|
|
|
|
variant="contained"
|
2023-12-26 12:57:44 +00:00
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "14px",
|
2023-12-27 11:48:25 +00:00
|
|
|
|
lineHeight: "18px",
|
|
|
|
|
height: "34px",
|
2023-12-29 15:37:13 +00:00
|
|
|
|
background: buttonText === "Опубликовано" ? "#FA5B0E" : "#7E2AEA",
|
2023-12-27 19:13:46 +00:00
|
|
|
|
p: "0 18px",
|
2023-12-27 21:36:33 +00:00
|
|
|
|
minWidth: "120px",
|
2023-12-26 12:57:44 +00:00
|
|
|
|
}}
|
2023-12-27 15:16:23 +00:00
|
|
|
|
onClick={handleClickStatusQuiz}
|
2023-12-26 12:57:44 +00:00
|
|
|
|
>
|
2023-12-27 15:16:23 +00:00
|
|
|
|
{buttonText === "Отозвать" ? (
|
|
|
|
|
<Box sx={{ display: "flex", gap: "4px", alignItems: "center" }}>
|
|
|
|
|
{buttonText} <BackButtonIcon />
|
|
|
|
|
</Box>
|
|
|
|
|
) : (
|
|
|
|
|
buttonText
|
|
|
|
|
)}
|
2023-12-27 11:48:25 +00:00
|
|
|
|
</Button>
|
2023-12-27 21:49:52 +00:00
|
|
|
|
{quiz?.status === "start" &&
|
|
|
|
|
(!isLinkButton ? (
|
|
|
|
|
<Box
|
|
|
|
|
component={Link}
|
|
|
|
|
sx={{
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
textOverflow: "ellipsis",
|
|
|
|
|
overflow: "hidden",
|
|
|
|
|
display: isMobile ? "none" : "block",
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
}}
|
|
|
|
|
target="_blank"
|
|
|
|
|
to={"https://hbpn.link/" + quiz.qid}
|
|
|
|
|
>
|
|
|
|
|
https://hbpn.link/{quiz.qid}
|
|
|
|
|
</Box>
|
|
|
|
|
) : (
|
|
|
|
|
<Box
|
|
|
|
|
component={Link}
|
|
|
|
|
sx={{
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
minWidth: "34px",
|
|
|
|
|
height: "34px",
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
display: isMobile ? "none" : "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "Center",
|
|
|
|
|
background: "#EEE4FC",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
}}
|
|
|
|
|
target="_blank"
|
|
|
|
|
to={"https://hbpn.link/" + quiz.qid}
|
|
|
|
|
>
|
|
|
|
|
<LinkSimple />
|
|
|
|
|
</Box>
|
|
|
|
|
))}
|
2023-12-27 15:16:23 +00:00
|
|
|
|
|
|
|
|
|
{isMobile ? (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={toggleQuizPreview}
|
|
|
|
|
variant="outlined"
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "4px",
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
lineHeight: "18px",
|
|
|
|
|
height: "34px",
|
|
|
|
|
border: "1px solid #7E2AEA",
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
background: "white",
|
|
|
|
|
p: "8px 14px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<EyeIcon />
|
|
|
|
|
Предпросмотр
|
|
|
|
|
</Button>
|
|
|
|
|
) : (
|
|
|
|
|
<IconButton
|
|
|
|
|
onClick={toggleQuizPreview}
|
|
|
|
|
sx={{
|
|
|
|
|
pointerEvents: "auto",
|
|
|
|
|
marginLeft: "auto",
|
|
|
|
|
position: "relative",
|
|
|
|
|
zIndex: "999999",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<VisibilityIcon sx={{ height: "30px", width: "30px" }} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{isMobile && quiz?.status === "start" && (
|
|
|
|
|
<Box
|
|
|
|
|
component={Link}
|
|
|
|
|
sx={{
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
width: "34px",
|
|
|
|
|
height: "34px",
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "Center",
|
|
|
|
|
background: "#EEE4FC",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
}}
|
|
|
|
|
target="_blank"
|
|
|
|
|
to={"https://hbpn.link/" + quiz.qid}
|
|
|
|
|
>
|
|
|
|
|
<LinkSimple />
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
2023-12-27 11:48:25 +00:00
|
|
|
|
</Box>
|
2023-12-21 08:29:51 +00:00
|
|
|
|
</Box>
|
2023-12-26 12:57:44 +00:00
|
|
|
|
</Box>
|
2023-12-19 13:42:43 +00:00
|
|
|
|
<ModalInfoWhyCantCreate />
|
2023-12-26 12:57:44 +00:00
|
|
|
|
<ConfirmLeaveModal
|
|
|
|
|
open={showConfirmLeaveModal}
|
|
|
|
|
follow={followNewPage}
|
|
|
|
|
cancel={() => setShowConfirmLeaveModal(false)}
|
|
|
|
|
/>
|
2023-12-19 19:55:59 +00:00
|
|
|
|
</>
|
|
|
|
|
);
|
2023-09-15 12:37:12 +00:00
|
|
|
|
}
|