кнопки открытия модалки информации о невозможности опубликоваться
This commit is contained in:
parent
3b4cab3de5
commit
520e4d255c
@ -33,7 +33,7 @@ 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 { cleanQuestions, setQuestions } from "@root/questions/actions";
|
import { cleanQuestions, setQuestions } from "@root/questions/actions";
|
||||||
import { updateOpenBranchingPanel, updateCanCreatePublic } from "@root/uiTools/actions";
|
import { updateOpenBranchingPanel, updateCanCreatePublic, updateModalInfoWhyCantCreate } from "@root/uiTools/actions";
|
||||||
import { BranchingPanel } from "../Questions/BranchingPanel";
|
import { BranchingPanel } from "../Questions/BranchingPanel";
|
||||||
import { useQuestionsStore } from "@root/questions/store";
|
import { useQuestionsStore } from "@root/questions/store";
|
||||||
import { useQuizes } from "@root/quizes/hooks";
|
import { useQuizes } from "@root/quizes/hooks";
|
||||||
@ -45,6 +45,7 @@ import { clearUserData } from "@root/user";
|
|||||||
import { clearAuthToken } from "@frontend/kitui";
|
import { clearAuthToken } from "@frontend/kitui";
|
||||||
import { logout } from "@api/auth";
|
import { logout } from "@api/auth";
|
||||||
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
||||||
|
import { ModalInfoWhyCantCreate } from "./ModalInfoWhyCantCreate";
|
||||||
|
|
||||||
export default function EditPage() {
|
export default function EditPage() {
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
@ -80,6 +81,7 @@ export default function EditPage() {
|
|||||||
() => () => {
|
() => () => {
|
||||||
resetEditConfig();
|
resetEditConfig();
|
||||||
cleanQuestions();
|
cleanQuestions();
|
||||||
|
updateModalInfoWhyCantCreate(false)
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
@ -112,7 +114,7 @@ export default function EditPage() {
|
|||||||
console.log(problems)
|
console.log(problems)
|
||||||
console.log(Object.keys(problems).length > 0)
|
console.log(Object.keys(problems).length > 0)
|
||||||
|
|
||||||
}, 1000);
|
}, 600);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -292,6 +294,7 @@ export default function EditPage() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
@ -366,6 +369,11 @@ export default function EditPage() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{
|
||||||
|
canCreatePublic ?
|
||||||
|
|
||||||
|
<>
|
||||||
{disableTest ? (
|
{disableTest ? (
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
@ -419,9 +427,18 @@ export default function EditPage() {
|
|||||||
color: "#7e2aea",
|
color: "#7e2aea",
|
||||||
fontSize: "14px"
|
fontSize: "14px"
|
||||||
}}
|
}}
|
||||||
target="_blank" to={"https://hbpn.link/" + quiz.qid}>https://hbpn.link/{quiz.qid}</Box>}
|
target="_blank" to={"https://hbpn.link/" + quiz.qid}>https://hbpn.link/{quiz.qid}
|
||||||
|
</Box>}
|
||||||
|
</>
|
||||||
|
:
|
||||||
|
<Button
|
||||||
|
onClick={() => updateModalInfoWhyCantCreate(true)}
|
||||||
|
>Почему я не могу создать публикацию</Button>
|
||||||
|
|
||||||
|
}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
<ModalInfoWhyCantCreate />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
48
src/pages/startPage/ModalInfoWhyCantCreate.tsx
Normal file
48
src/pages/startPage/ModalInfoWhyCantCreate.tsx
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import { Box, Modal, Typography, Divider } from "@mui/material"
|
||||||
|
|
||||||
|
import { useUiTools } from "@root/uiTools/store";
|
||||||
|
import { updateModalInfoWhyCantCreate } from "@root/uiTools/actions";
|
||||||
|
|
||||||
|
export const ModalInfoWhyCantCreate = () => {
|
||||||
|
|
||||||
|
const { whyCantCreatePublic, openModalInfoWhyCantCreate } = useUiTools();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
open={openModalInfoWhyCantCreate}
|
||||||
|
onClose={() => updateModalInfoWhyCantCreate(false)}
|
||||||
|
>
|
||||||
|
<Box sx={{
|
||||||
|
position: 'absolute' as 'absolute',
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
maxWidth: '620px',
|
||||||
|
width: '100%',
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
borderRadius: '12px',
|
||||||
|
|
||||||
|
boxShadow: 24,
|
||||||
|
p: "25px",
|
||||||
|
minHeight: "60vh",
|
||||||
|
maxHeight: "90vh",
|
||||||
|
overflow: "auto"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
Object.values(whyCantCreatePublic).map((data) => {
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Typography color="#7e2aea">У вопроса "{data.name}"</Typography>
|
||||||
|
{
|
||||||
|
data.problems.map((problem) => <Typography p="5px 0">{problem}</Typography>)
|
||||||
|
}
|
||||||
|
<Divider/>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -34,4 +34,6 @@ export const updateEditSomeQuestion = (contentId?: string) => {
|
|||||||
export const updateOpenedModalSettingsId = (id?: string) => useUiTools.setState({ openedModalSettingsId: id ? id : null });
|
export const updateOpenedModalSettingsId = (id?: string) => useUiTools.setState({ openedModalSettingsId: id ? id : null });
|
||||||
|
|
||||||
|
|
||||||
export const updateCanCreatePublic = (can?: boolean) => useUiTools.setState({ canCreatePublic: can ? can : false });
|
export const updateCanCreatePublic = (can: boolean) => useUiTools.setState({ canCreatePublic: can });
|
||||||
|
|
||||||
|
export const updateModalInfoWhyCantCreate = (can: boolean) => useUiTools.setState({ openModalInfoWhyCantCreate: can });
|
||||||
@ -10,6 +10,7 @@ export type UiTools = {
|
|||||||
editSomeQuestion: string | null;
|
editSomeQuestion: string | null;
|
||||||
canCreatePublic: boolean;
|
canCreatePublic: boolean;
|
||||||
whyCantCreatePublic: Record<string, WhyCantCreatePublic>//ид вопроса и список претензий к нему
|
whyCantCreatePublic: Record<string, WhyCantCreatePublic>//ид вопроса и список претензий к нему
|
||||||
|
openModalInfoWhyCantCreate: boolean;
|
||||||
};
|
};
|
||||||
export type WhyCantCreatePublic = {
|
export type WhyCantCreatePublic = {
|
||||||
name: string;
|
name: string;
|
||||||
@ -24,7 +25,8 @@ const initialState: UiTools = {
|
|||||||
desireToOpenABranchingModal: null as null,
|
desireToOpenABranchingModal: null as null,
|
||||||
editSomeQuestion: null as null,
|
editSomeQuestion: null as null,
|
||||||
canCreatePublic: false,
|
canCreatePublic: false,
|
||||||
whyCantCreatePublic: {}
|
whyCantCreatePublic: {},
|
||||||
|
openModalInfoWhyCantCreate: false
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useUiTools = create<UiTools>()(
|
export const useUiTools = create<UiTools>()(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user