переключение страницы дизайна
This commit is contained in:
parent
dfae356f45
commit
1fd41bdc2c
@ -48,23 +48,6 @@ export const DesignPage = () => {
|
|||||||
const quizes = await quizApi.getList();
|
const quizes = await quizApi.getList();
|
||||||
setQuizes(quizes);
|
setQuizes(quizes);
|
||||||
|
|
||||||
if (editQuizId) {
|
|
||||||
const questions = await questionApi.getList({ quiz_id: editQuizId });
|
|
||||||
setQuestions(questions);
|
|
||||||
//Всегда должен существовать хоть 1 резулт - "line"
|
|
||||||
// console.log("сейчас будем ворошиться в этих квешенах ", questions);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!questions?.find(
|
|
||||||
(q) =>
|
|
||||||
(q.type === "result" && q.content.includes(':"line"')) ||
|
|
||||||
q.content.includes(":'line'")
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
createResult(quiz?.backendId, "line");
|
|
||||||
console.log("Я не нашёл линейный резулт и собираюсь создать новый");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
getData();
|
getData();
|
||||||
}, []);
|
}, []);
|
||||||
@ -76,57 +59,25 @@ export const DesignPage = () => {
|
|||||||
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
||||||
const [mobileSidebar, setMobileSidebar] = useState<boolean>(false);
|
const [mobileSidebar, setMobileSidebar] = useState<boolean>(false);
|
||||||
const [nextStep, setNextStep] = useState<number>(0);
|
const [nextStep, setNextStep] = useState<number>(0);
|
||||||
const quizConfig = quiz?.config;
|
|
||||||
const [openBranchingPage, setOpenBranchingPage] = useState<boolean>(false);
|
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
resetEditConfig();
|
|
||||||
cleanQuestions();
|
cleanQuestions();
|
||||||
updateModalInfoWhyCantCreate(false);
|
updateModalInfoWhyCantCreate(false);
|
||||||
updateSomeWorkBackend(false);
|
updateSomeWorkBackend(false);
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
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";
|
|
||||||
});
|
|
||||||
updateCanCreatePublic(false);
|
|
||||||
} else {
|
|
||||||
updateCanCreatePublic(true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
600
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateQuestionHint(questions);
|
if (editQuizId === null) navigate("/list");
|
||||||
}, [questions]);
|
}, [navigate, editQuizId]);
|
||||||
|
|
||||||
async function handleLogoutClick() {
|
|
||||||
const [, logoutError] = await logout();
|
|
||||||
|
|
||||||
if (logoutError) {
|
|
||||||
return enqueueSnackbar(logoutError);
|
|
||||||
}
|
|
||||||
|
|
||||||
clearAuthToken();
|
|
||||||
clearUserData();
|
|
||||||
navigate("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
const followNewPage = () => {
|
const followNewPage = () => {
|
||||||
setShowConfirmLeaveModal(false);
|
setShowConfirmLeaveModal(false);
|
||||||
setCurrentStep(nextStep);
|
setCurrentStep(nextStep);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!quizConfig) return <></>;
|
|
||||||
|
|
||||||
const changePage = (index: number) => {
|
const changePage = (index: number) => {
|
||||||
if (currentStep === 2) {
|
if (currentStep === 2) {
|
||||||
@ -139,6 +90,8 @@ export const DesignPage = () => {
|
|||||||
setCurrentStep(index);
|
setCurrentStep(index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(quiz)
|
||||||
|
if (!quiz) return <></>;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header setMobileSidebar={setMobileSidebar} />
|
<Header setMobileSidebar={setMobileSidebar} />
|
||||||
|
@ -128,7 +128,7 @@ export default function EditPage() {
|
|||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
resetEditConfig();
|
// resetEditConfig();
|
||||||
cleanQuestions();
|
cleanQuestions();
|
||||||
updateModalInfoWhyCantCreate(false);
|
updateModalInfoWhyCantCreate(false);
|
||||||
updateSomeWorkBackend(false);
|
updateSomeWorkBackend(false);
|
||||||
|
@ -127,14 +127,14 @@ export const Header = ({ setMobileSidebar }: HeaderProps) => {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Box>
|
<Box>
|
||||||
<CustomAvatar
|
{/* <CustomAvatar
|
||||||
sx={{
|
sx={{
|
||||||
ml: "11px",
|
ml: "11px",
|
||||||
backgroundColor: theme.palette.orange.main,
|
backgroundColor: theme.palette.orange.main,
|
||||||
height: "36px",
|
height: "36px",
|
||||||
width: "36px",
|
width: "36px",
|
||||||
}}
|
}}
|
||||||
/>
|
/> */}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
@ -148,11 +148,11 @@ export const Header = ({ setMobileSidebar }: HeaderProps) => {
|
|||||||
ml: "20px",
|
ml: "20px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NavMenuItem text="Редактировать" isActive />
|
{/* <NavMenuItem text="Редактировать" isActive /> */}
|
||||||
<NavMenuItem text="Заявки" />
|
{/* <NavMenuItem text="Заявки" />
|
||||||
<NavMenuItem text="Аналитика" />
|
<NavMenuItem text="Аналитика" />
|
||||||
<NavMenuItem text="История" />
|
<NavMenuItem text="История" />
|
||||||
<NavMenuItem text="Помощь" />
|
<NavMenuItem text="Помощь" /> */}
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -161,14 +161,14 @@ export const Header = ({ setMobileSidebar }: HeaderProps) => {
|
|||||||
gap: "15px",
|
gap: "15px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CustomAvatar
|
{/* <CustomAvatar
|
||||||
sx={{
|
sx={{
|
||||||
ml: "11px",
|
ml: "11px",
|
||||||
backgroundColor: theme.palette.orange.main,
|
backgroundColor: theme.palette.orange.main,
|
||||||
height: "36px",
|
height: "36px",
|
||||||
width: "36px",
|
width: "36px",
|
||||||
}}
|
}}
|
||||||
/>
|
/> */}
|
||||||
<LogoutButton onClick={handleLogoutClick} />
|
<LogoutButton onClick={handleLogoutClick} />
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
|
@ -79,11 +79,11 @@ export default function Header() {
|
|||||||
ml: "20px",
|
ml: "20px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NavMenuItem text="Редактировать" isActive />
|
{/* <NavMenuItem text="Редактировать" isActive /> */}
|
||||||
<NavMenuItem text="Заявки" />
|
{/* <NavMenuItem text="Заявки" />
|
||||||
<NavMenuItem text="Аналитика" />
|
<NavMenuItem text="Аналитика" />
|
||||||
<NavMenuItem text="История" />
|
<NavMenuItem text="История" />
|
||||||
<NavMenuItem text="Помощь" />
|
<NavMenuItem text="Помощь" /> */}
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -92,9 +92,9 @@ export default function Header() {
|
|||||||
gap: "15px",
|
gap: "15px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CustomAvatar
|
{/* <CustomAvatar
|
||||||
sx={{ ml: "11px", backgroundColor: theme.palette.orange.main, height: "36px", width: "36px" }}
|
sx={{ ml: "11px", backgroundColor: theme.palette.orange.main, height: "36px", width: "36px" }}
|
||||||
/>
|
/> */}
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -63,17 +63,17 @@ export default function HeaderFull() {
|
|||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NavMenuItem text="Квизы" />
|
{/* <NavMenuItem text="Квизы" />
|
||||||
<NavMenuItem text="Меню 2" isActive />
|
<NavMenuItem text="Меню 2" isActive />
|
||||||
<NavMenuItem text="Меню 3" />
|
<NavMenuItem text="Меню 3" />
|
||||||
<NavMenuItem text="Меню 4" />
|
<NavMenuItem text="Меню 4" />
|
||||||
<NavMenuItem text="Меню 5" />
|
<NavMenuItem text="Меню 5" />
|
||||||
<NavMenuItem text="Меню 1" />
|
<NavMenuItem text="Меню 1" />
|
||||||
<NavMenuItem text="Меню 2" />
|
<NavMenuItem text="Меню 2" /> */}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
<Box sx={{ display: isMobile ? "none" : "flex", ml: "auto" }}>
|
<Box sx={{ display: isMobile ? "none" : "flex", ml: "auto" }}>
|
||||||
{!isTablet && (
|
{/* {!isTablet && (
|
||||||
<>
|
<>
|
||||||
<IconButton sx={{ p: 0 }}>
|
<IconButton sx={{ p: 0 }}>
|
||||||
<WalletIcon color={theme.palette.grey2.main} bgcolor="#F2F3F7" />
|
<WalletIcon color={theme.palette.grey2.main} bgcolor="#F2F3F7" />
|
||||||
@ -93,17 +93,17 @@ export default function HeaderFull() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
)}
|
)} */}
|
||||||
{!isMobile && (
|
{!isMobile && (
|
||||||
<>
|
<>
|
||||||
<CustomAvatar
|
{/* <CustomAvatar
|
||||||
sx={{
|
sx={{
|
||||||
ml: "27px",
|
ml: "27px",
|
||||||
backgroundColor: theme.palette.orange.main,
|
backgroundColor: theme.palette.orange.main,
|
||||||
height: "36px",
|
height: "36px",
|
||||||
width: "36px",
|
width: "36px",
|
||||||
}}
|
}}
|
||||||
/>
|
/> */}
|
||||||
<LogoutButton
|
<LogoutButton
|
||||||
onClick={handleLogoutClick}
|
onClick={handleLogoutClick}
|
||||||
sx={{
|
sx={{
|
||||||
|
@ -130,7 +130,7 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</List>
|
</List>
|
||||||
{/* {!isMenuCollapsed && (
|
{!isMenuCollapsed && (
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
px: "16px",
|
px: "16px",
|
||||||
@ -144,8 +144,36 @@ export default function Sidebar({ changePage, disableCollapse }: SidebarProps) {
|
|||||||
>
|
>
|
||||||
Настройки квиза
|
Настройки квиза
|
||||||
</Typography>
|
</Typography>
|
||||||
)} */}
|
)}
|
||||||
<List disablePadding>
|
<List disablePadding>
|
||||||
|
<MenuItem
|
||||||
|
onClick={()=>navigate("/design")}
|
||||||
|
text={"Дизайн"}
|
||||||
|
isCollapsed={isMenuCollapsed}
|
||||||
|
isActive={currentStep === 6}
|
||||||
|
disabled={
|
||||||
|
currentStep === 6
|
||||||
|
? false
|
||||||
|
: quiz === undefined
|
||||||
|
? true
|
||||||
|
: quiz?.config.type === null
|
||||||
|
}
|
||||||
|
icon={
|
||||||
|
<PencilCircleIcon
|
||||||
|
color={
|
||||||
|
currentStep === 6
|
||||||
|
? theme.palette.brightPurple.main
|
||||||
|
: isMenuCollapsed
|
||||||
|
? "white"
|
||||||
|
: theme.palette.grey2.main
|
||||||
|
}
|
||||||
|
height={isMenuCollapsed ? "35px" : "24px"}
|
||||||
|
width={isMenuCollapsed ? "35px" : "24px"}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
{/* {quizSettingsMenuItems.map((menuItem, index) => {
|
{/* {quizSettingsMenuItems.map((menuItem, index) => {
|
||||||
const Icon = menuItem[0];
|
const Icon = menuItem[0];
|
||||||
const totalIndex = index + quizSetupSteps.length;
|
const totalIndex = index + quizSetupSteps.length;
|
||||||
|
Loading…
Reference in New Issue
Block a user