фикс расположения нижнего меню

This commit is contained in:
ArtChaos189 2023-12-27 14:48:25 +03:00
parent 051aa27dda
commit db9b421066
3 changed files with 129 additions and 195 deletions

@ -7,42 +7,27 @@ import { useQuestionsStore } from "@root/questions/store";
import { useUiTools } from "@root/uiTools/store"; import { useUiTools } from "@root/uiTools/store";
import { useQuestions } from "@root/questions/hooks"; import { useQuestions } from "@root/questions/hooks";
import { useCurrentQuiz } from "@root/quizes/hooks"; import { useCurrentQuiz } from "@root/quizes/hooks";
import { updateSomeWorkBackend } from "@root/uiTools/actions";
import {
copyQuestion,
deleteQuestion,
deleteQuestionWithTimeout,
clearRuleForAll,
updateQuestion,
getQuestionByContentId,
} from "@root/questions/actions";
import { updateRootContentId } from "@root/quizes/actions";
import type { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
import { DeleteFunction } from "@utils/deleteFunc";
import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions"; import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
interface Props { interface Props {
openBranchingPage: boolean; openBranchingPage: boolean;
setOpenBranchingPage: (a:boolean) => void; setOpenBranchingPage: (a: boolean) => void;
} }
export const QuestionSwitchWindowTool = ({ export const QuestionSwitchWindowTool = ({ openBranchingPage, setOpenBranchingPage }: Props) => {
openBranchingPage,
setOpenBranchingPage}:Props) => {
const { questions } = useQuestionsStore.getState(); const { questions } = useQuestionsStore.getState();
const theme = useTheme(); const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down(600)); const isMobile = useMediaQuery(theme.breakpoints.down(600));
const quiz = useCurrentQuiz(); const quiz = useCurrentQuiz();
console.log("Я компонент в котором отвечала") console.log("Я компонент в котором отвечала");
const openBranchingPageHC = () => { const openBranchingPageHC = () => {
if (!openBranchingPage) { if (!openBranchingPage) {
deleteTimeoutedQuestions(questions, quiz) deleteTimeoutedQuestions(questions, quiz);
} }
setOpenBranchingPage(!openBranchingPage) setOpenBranchingPage(!openBranchingPage);
} };
return ( return (
<Box <Box
@ -53,14 +38,10 @@ export const QuestionSwitchWindowTool = ({
marginBottom: isMobile ? "20px" : undefined, marginBottom: isMobile ? "20px" : undefined,
}} }}
> >
<Box sx={{ flexBasis: "796px" }}> <Box sx={{ flexBasis: "796px" }}>{openBranchingPage ? <BranchingMap /> : <DraggableList />}</Box>
{openBranchingPage ? <BranchingMap /> : <DraggableList />} {openBranchingPage && (
</Box> <SwitchBranchingPanel openBranchingPage={openBranchingPage} setOpenBranchingPage={openBranchingPageHC} />
<SwitchBranchingPanel )}
openBranchingPage={openBranchingPage}
setOpenBranchingPage={openBranchingPageHC}
/>
</Box> </Box>
); );
}; };

@ -15,12 +15,10 @@ import { useUiTools } from "@root/uiTools/store";
interface Props { interface Props {
openBranchingPage: boolean; openBranchingPage: boolean;
setOpenBranchingPage: (a:boolean) => void; setOpenBranchingPage: (a: boolean) => void;
} }
export default function QuestionsPage({ export default function QuestionsPage({ openBranchingPage, setOpenBranchingPage }: Props) {
openBranchingPage,
setOpenBranchingPage}:Props) {
const theme = useTheme(); const theme = useTheme();
const { openedModalSettingsId, openBranchingPanel } = useUiTools(); const { openedModalSettingsId, openBranchingPanel } = useUiTools();
const isMobile = useMediaQuery(theme.breakpoints.down(660)); const isMobile = useMediaQuery(theme.breakpoints.down(660));
@ -62,10 +60,7 @@ export default function QuestionsPage({
Свернуть всё Свернуть всё
</Button> </Button>
</Box> </Box>
<QuestionSwitchWindowTool <QuestionSwitchWindowTool openBranchingPage={openBranchingPage} setOpenBranchingPage={setOpenBranchingPage} />
openBranchingPage={openBranchingPage}
setOpenBranchingPage={setOpenBranchingPage}
/>
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",

@ -16,13 +16,7 @@ import {
useMediaQuery, useMediaQuery,
useTheme, useTheme,
} from "@mui/material"; } from "@mui/material";
import { import { decrementCurrentStep, resetEditConfig, setQuizes, updateQuiz, setCurrentStep } from "@root/quizes/actions";
decrementCurrentStep,
resetEditConfig,
setQuizes,
updateQuiz,
setCurrentStep,
} from "@root/quizes/actions";
import { useCurrentQuiz } from "@root/quizes/hooks"; import { useCurrentQuiz } from "@root/quizes/hooks";
import { useQuizStore } from "@root/quizes/store"; import { useQuizStore } from "@root/quizes/store";
import CustomAvatar from "@ui_kit/Header/Avatar"; import CustomAvatar from "@ui_kit/Header/Avatar";
@ -38,11 +32,7 @@ import { Link, useNavigate } from "react-router-dom";
import useSWR from "swr"; import useSWR from "swr";
import { useDebouncedCallback } from "use-debounce"; import { useDebouncedCallback } from "use-debounce";
import { SidebarMobile } from "./Sidebar/SidebarMobile"; import { SidebarMobile } from "./Sidebar/SidebarMobile";
import { import { cleanQuestions, createResult, setQuestions } from "@root/questions/actions";
cleanQuestions,
createResult,
setQuestions,
} from "@root/questions/actions";
import { import {
updateOpenBranchingPanel, updateOpenBranchingPanel,
updateCanCreatePublic, updateCanCreatePublic,
@ -65,13 +55,13 @@ import { ConfirmLeaveModal } from "./ConfirmLeaveModal";
import { checkQuestionHint } from "@utils/checkQuestionHint"; import { checkQuestionHint } from "@utils/checkQuestionHint";
import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions"; import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
let init:() => void let init: () => void;
export default function EditPage() { export default function EditPage() {
const quiz = useCurrentQuiz(); const quiz = useCurrentQuiz();
const { editQuizId } = useQuizStore(); const { editQuizId } = useQuizStore();
const { questions } = useQuestionsStore(); const { questions } = useQuestionsStore();
console.log('quiz ',quiz); console.log("quiz ", quiz);
console.log(questions); console.log(questions);
useEffect(() => { useEffect(() => {
const getData = async () => { const getData = async () => {
@ -86,26 +76,18 @@ export default function EditPage() {
if ( if (
!questions?.find( !questions?.find(
(q) => (q) => (q.type === "result" && q.content.includes(':"line"')) || q.content.includes(":'line'")
(q.type === "result" && q.content.includes(':"line"')) ||
q.content.includes(":'line'")
) )
) { ) {
createResult(quiz?.backendId, "line"); createResult(quiz?.backendId, "line");
console.log("Я не нашёл линейный резулт и собираюсь создать новый") console.log("Я не нашёл линейный резулт и собираюсь создать новый");
} }
} }
}; };
getData(); getData();
}, []); }, []);
const { const { openBranchingPanel, whyCantCreatePublic, canCreatePublic, showConfirmLeaveModal } = useUiTools();
openBranchingPanel,
whyCantCreatePublic,
canCreatePublic,
showConfirmLeaveModal,
} = 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);
@ -119,10 +101,10 @@ export default function EditPage() {
const openBranchingPageHC = () => { const openBranchingPageHC = () => {
if (!openBranchingPage) { if (!openBranchingPage) {
deleteTimeoutedQuestions(questions, quiz) deleteTimeoutedQuestions(questions, quiz);
} }
setOpenBranchingPage(old => !old) setOpenBranchingPage((old) => !old);
} };
useEffect(() => { useEffect(() => {
if (editQuizId === null) navigate("/list"); if (editQuizId === null) navigate("/list");
@ -137,21 +119,18 @@ export default function EditPage() {
[] []
); );
const updateQuestionHint = useDebouncedCallback( const updateQuestionHint = useDebouncedCallback((questions: AnyTypedQuizQuestion[]) => {
(questions: AnyTypedQuizQuestion[]) => { const problems = checkQuestionHint(questions);
const problems = checkQuestionHint(questions); useUiTools.setState({ whyCantCreatePublic: problems });
useUiTools.setState({ whyCantCreatePublic: problems }); if (Object.keys(problems).length > 0) {
if (Object.keys(problems).length > 0) { updateQuiz(quiz?.id, (state) => {
updateQuiz(quiz?.id, (state) => { state.status = "stop";
state.status = "stop"; });
}); updateCanCreatePublic(false);
updateCanCreatePublic(false); } else {
} else { updateCanCreatePublic(true);
updateCanCreatePublic(true); }
} }, 600);
},
600
);
useEffect(() => { useEffect(() => {
updateQuestionHint(questions); updateQuestionHint(questions);
@ -175,6 +154,8 @@ export default function EditPage() {
}; };
if (!quizConfig) return <></>; if (!quizConfig) return <></>;
const isConditionMet = [1].includes(currentStep) && !openBranchingPanel && quizConfig.type !== "form";
return ( return (
<> <>
{/*хедер*/} {/*хедер*/}
@ -308,45 +289,44 @@ export default function EditPage() {
sx={{ sx={{
background: theme.palette.background.default, background: theme.palette.background.default,
width: "100%", width: "100%",
padding: isMobile ? "16px 16px 140px 16px" : "25px 25px 140px 25px",
height: "calc(100vh - 80px)",
overflow: "auto",
boxSizing: "border-box",
}} }}
> >
{/* Выбор текущей страницы редактирования чего-либо находится здесь */} <Box
{quizConfig && ( sx={{
<> padding: isMobile ? "16px 16px 20px 16px" : "25px 25px 20px 25px",
<Stepper activeStep={currentStep} /> overflow: "auto",
<SwitchStepPages height: `calc(100vh - ${isConditionMet ? "186px" : "156px"})`,
activeStep={currentStep}
quizType={quizConfig.type}
quizResults={quizConfig.results}
quizStartPageType={quizConfig.startpageType}
openBranchingPage={openBranchingPage}
setOpenBranchingPage={setOpenBranchingPage}
/>
</>
)}
</Box>
<Box boxSizing: "border-box",
sx={{ }}
position: "absolute", >
left: 0, {/* Выбор текущей страницы редактирования чего-либо находится здесь */}
bottom: 0, {quizConfig && (
width: "100%", <>
padding: isMobile ? "20px 16px" : "20px 40px 20px 250px", <Stepper activeStep={currentStep} />
display: "flex", <SwitchStepPages
justifyContent: "flex-start", activeStep={currentStep}
alignItems: "center", quizType={quizConfig.type}
gap: "15px", quizResults={quizConfig.results}
background: "#FFF", quizStartPageType={quizConfig.startpageType}
}} openBranchingPage={openBranchingPage}
> setOpenBranchingPage={setOpenBranchingPage}
{[1].includes(currentStep) && />
!openBranchingPanel && </>
quizConfig.type !== "form" && ( )}
</Box>
<Box
sx={{
width: "100%",
padding: isMobile ? "20px 16px" : "20px 20px",
display: "flex",
justifyContent: "flex-start",
alignItems: "center",
gap: "15px",
background: "#FFF",
}}
>
{isConditionMet && (
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
@ -380,10 +360,7 @@ export default function EditPage() {
"&.Mui-disabled + .MuiSwitch-track": { opacity: 0.5 }, "&.Mui-disabled + .MuiSwitch-track": { opacity: 0.5 },
}, },
"&.Mui-disabled .MuiSwitch-thumb": { "&.Mui-disabled .MuiSwitch-thumb": {
color: color: theme.palette.mode === "light" ? theme.palette.grey[100] : theme.palette.grey[600],
theme.palette.mode === "light"
? theme.palette.grey[100]
: theme.palette.grey[600],
}, },
"&.Mui-disabled + .MuiSwitch-track": { "&.Mui-disabled + .MuiSwitch-track": {
opacity: theme.palette.mode === "light" ? 0.7 : 0.3, opacity: theme.palette.mode === "light" ? 0.7 : 0.3,
@ -396,106 +373,87 @@ export default function EditPage() {
}, },
"& .MuiSwitch-track": { "& .MuiSwitch-track": {
borderRadius: 13, borderRadius: 13,
backgroundColor: backgroundColor: theme.palette.mode === "light" ? "#E9E9EA" : "#39393D",
theme.palette.mode === "light" ? "#E9E9EA" : "#39393D",
opacity: 1, opacity: 1,
transition: theme.transitions.create( transition: theme.transitions.create(["background-color"], {
["background-color"], duration: 500,
{ }),
duration: 500,
}
),
}, },
}} }}
/> />
<Box> <Box>
<Typography sx={{ fontWeight: "bold", color: "#4D4D4D" }}> <Typography sx={{ fontWeight: "bold", color: "#4D4D4D" }}>Логика ветвления</Typography>
Логика ветвления
</Typography>
</Box> </Box>
</Box> </Box>
)} )}
{!canCreatePublic && quiz.config.type !== "form" ? ( {!canCreatePublic && quiz.config.type !== "form" ? (
<Button
variant="contained"
// disabled
sx={{
fontSize: "14px",
lineHeight: "18px",
height: "34px",
minWidth: "130px",
}}
onClick={() =>
Object.keys(whyCantCreatePublic).length === 0
? () => { }
: updateModalInfoWhyCantCreate(true)
}
>
Тестовый просмотр
</Button>
) : (
<a
href={`/view`}
target="_blank"
rel="noreferrer"
style={{ textDecoration: "none" }}
>
<Button <Button
variant="contained" variant="contained"
// disabled
sx={{ sx={{
fontSize: "14px", fontSize: "14px",
lineHeight: "18px", lineHeight: "18px",
height: "34px", height: "34px",
minWidth: "130px", minWidth: "130px",
}} }}
onClick={() =>
Object.keys(whyCantCreatePublic).length === 0 ? () => {} : updateModalInfoWhyCantCreate(true)
}
> >
Тестовый просмотр Тестовый просмотр
</Button> </Button>
</a> ) : (
)} <a href={`/view`} target="_blank" rel="noreferrer" style={{ textDecoration: "none" }}>
<Button
variant="contained"
sx={{
fontSize: "14px",
lineHeight: "18px",
height: "34px",
minWidth: "130px",
}}
>
Тестовый просмотр
</Button>
</a>
)}
<Button <Button
variant="outlined" variant="outlined"
sx={{
fontSize: "14px",
lineHeight: "18px",
height: "34px",
border: `1px solid ${theme.palette.brightPurple.main}`,
backgroundColor:
quiz?.status === "start"
? theme.palette.brightPurple.main
: "transparent",
color:
quiz?.status === "start"
? "#FFFFFF"
: theme.palette.brightPurple.main,
}}
onClick={
Object.keys(whyCantCreatePublic).length === 0
? () =>
updateQuiz(quiz?.id, (state) => {
state.status =
quiz?.status === "start" ? "stop" : "start";
})
: () => updateModalInfoWhyCantCreate(true)
}
>
{quiz?.status === "start" ? "Стоп" : "Старт"}
</Button>
{quiz?.status === "start" && (
<Box
component={Link}
sx={{ sx={{
color: "#7e2aea",
fontSize: "14px", fontSize: "14px",
lineHeight: "18px",
height: "34px",
border: `1px solid ${theme.palette.brightPurple.main}`,
backgroundColor: quiz?.status === "start" ? theme.palette.brightPurple.main : "transparent",
color: quiz?.status === "start" ? "#FFFFFF" : theme.palette.brightPurple.main,
}} }}
target="_blank" onClick={
to={"https://hbpn.link/" + quiz.qid} Object.keys(whyCantCreatePublic).length === 0
? () =>
updateQuiz(quiz?.id, (state) => {
state.status = quiz?.status === "start" ? "stop" : "start";
})
: () => updateModalInfoWhyCantCreate(true)
}
> >
https://hbpn.link/{quiz.qid} {quiz?.status === "start" ? "Стоп" : "Старт"}
</Box> </Button>
)} {quiz?.status === "start" && (
<Box
component={Link}
sx={{
color: "#7e2aea",
fontSize: "14px",
}}
target="_blank"
to={"https://hbpn.link/" + quiz.qid}
>
https://hbpn.link/{quiz.qid}
</Box>
)}
</Box>
</Box> </Box>
</Box> </Box>
<ModalInfoWhyCantCreate /> <ModalInfoWhyCantCreate />