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