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

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,20 +7,7 @@ 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 {
@ -28,21 +15,19 @@ interface Props {
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>
); );
}; };

@ -18,9 +18,7 @@ interface Props {
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,8 +119,7 @@ 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) {
@ -149,9 +130,7 @@ export default function EditPage() {
} 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,9 +289,14 @@ 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)", >
<Box
sx={{
padding: isMobile ? "16px 16px 20px 16px" : "25px 25px 20px 25px",
overflow: "auto", overflow: "auto",
height: `calc(100vh - ${isConditionMet ? "186px" : "156px"})`,
boxSizing: "border-box", boxSizing: "border-box",
}} }}
> >
@ -329,14 +315,10 @@ export default function EditPage() {
</> </>
)} )}
</Box> </Box>
<Box <Box
sx={{ sx={{
position: "absolute",
left: 0,
bottom: 0,
width: "100%", width: "100%",
padding: isMobile ? "20px 16px" : "20px 40px 20px 250px", padding: isMobile ? "20px 16px" : "20px 20px",
display: "flex", display: "flex",
justifyContent: "flex-start", justifyContent: "flex-start",
alignItems: "center", alignItems: "center",
@ -344,9 +326,7 @@ export default function EditPage() {
background: "#FFF", background: "#FFF",
}} }}
> >
{[1].includes(currentStep) && {isConditionMet && (
!openBranchingPanel &&
quizConfig.type !== "form" && (
<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,22 +373,16 @@ 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>
)} )}
@ -427,20 +398,13 @@ export default function EditPage() {
minWidth: "130px", minWidth: "130px",
}} }}
onClick={() => onClick={() =>
Object.keys(whyCantCreatePublic).length === 0 Object.keys(whyCantCreatePublic).length === 0 ? () => {} : updateModalInfoWhyCantCreate(true)
? () => { }
: updateModalInfoWhyCantCreate(true)
} }
> >
Тестовый просмотр Тестовый просмотр
</Button> </Button>
) : ( ) : (
<a <a href={`/view`} target="_blank" rel="noreferrer" style={{ textDecoration: "none" }}>
href={`/view`}
target="_blank"
rel="noreferrer"
style={{ textDecoration: "none" }}
>
<Button <Button
variant="contained" variant="contained"
sx={{ sx={{
@ -462,21 +426,14 @@ export default function EditPage() {
lineHeight: "18px", lineHeight: "18px",
height: "34px", height: "34px",
border: `1px solid ${theme.palette.brightPurple.main}`, border: `1px solid ${theme.palette.brightPurple.main}`,
backgroundColor: backgroundColor: quiz?.status === "start" ? theme.palette.brightPurple.main : "transparent",
quiz?.status === "start" color: quiz?.status === "start" ? "#FFFFFF" : theme.palette.brightPurple.main,
? theme.palette.brightPurple.main
: "transparent",
color:
quiz?.status === "start"
? "#FFFFFF"
: theme.palette.brightPurple.main,
}} }}
onClick={ onClick={
Object.keys(whyCantCreatePublic).length === 0 Object.keys(whyCantCreatePublic).length === 0
? () => ? () =>
updateQuiz(quiz?.id, (state) => { updateQuiz(quiz?.id, (state) => {
state.status = state.status = quiz?.status === "start" ? "stop" : "start";
quiz?.status === "start" ? "stop" : "start";
}) })
: () => updateModalInfoWhyCantCreate(true) : () => updateModalInfoWhyCantCreate(true)
} }
@ -498,6 +455,7 @@ export default function EditPage() {
)} )}
</Box> </Box>
</Box> </Box>
</Box>
<ModalInfoWhyCantCreate /> <ModalInfoWhyCantCreate />
<ConfirmLeaveModal <ConfirmLeaveModal
open={showConfirmLeaveModal} open={showConfirmLeaveModal}