открытие модалки ветвления с помощью стора

This commit is contained in:
Tamara 2023-07-14 21:29:09 +03:00
parent a38ea6987a
commit 3b4c5aaafb
6 changed files with 22 additions and 32 deletions

@ -18,9 +18,13 @@ interface Props {
export default function ButtonsOptions({ SSHC, switchState, totalIndex }: Props) { export default function ButtonsOptions({ SSHC, switchState, totalIndex }: Props) {
const params = Number(useParams().quizId); const params = Number(useParams().quizId);
const {listQuestions, updateQuestionsList, createQuestion, removeQuestion} = questionStore() const {listQuestions, updateQuestionsList, createQuestion, removeQuestion, openedModalSettings, createOpenedModalSettings} = questionStore()
const openedModal = () => {
createOpenedModalSettings({openedModalSettings: "open"})
console.log(openedModalSettings)
}
const theme = useTheme(); const theme = useTheme();
const buttonSetting: { icon: JSX.Element; title: string; value: string }[] = [ const buttonSetting: { icon: JSX.Element; title: string; value: string; myFunc?: any }[] = [
{ {
icon: <SettingIcon color={switchState === "setting" ? "#ffffff" : theme.palette.grey3.main} />, icon: <SettingIcon color={switchState === "setting" ? "#ffffff" : theme.palette.grey3.main} />,
title: "Настройки", title: "Настройки",
@ -35,6 +39,7 @@ export default function ButtonsOptions({ SSHC, switchState, totalIndex }: Props)
icon: <Branching color={switchState === "branching" ? "#ffffff" : theme.palette.grey3.main} />, icon: <Branching color={switchState === "branching" ? "#ffffff" : theme.palette.grey3.main} />,
title: "Ветвление", title: "Ветвление",
value: "branching", value: "branching",
myFunc: openedModal
}, },
]; ];
@ -54,11 +59,12 @@ export default function ButtonsOptions({ SSHC, switchState, totalIndex }: Props)
gap: "10px", gap: "10px",
}} }}
> >
{buttonSetting.map(({ icon, title, value }) => ( {buttonSetting.map(({ icon, title, value, myFunc}) => (
<MiniButtonSetting <MiniButtonSetting
key={title} key={title}
onClick={() => { onClick={() => {
SSHC(value); SSHC(value);
{myFunc()}
}} }}
sx={{ sx={{
backgroundColor: switchState === value ? theme.palette.brightPurple.main : "transparent", backgroundColor: switchState === value ? theme.palette.brightPurple.main : "transparent",

@ -20,9 +20,8 @@ interface Props {
export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: Props) { export default function ButtonsOptionsAndPict({ SSHC, switchState, totalIndex }: Props) {
const params = Number(useParams().quizId); const params = Number(useParams().quizId);
const {listQuestions, updateQuestionsList, createQuestion, removeQuestion, openedModalSettings, createOpenedModalSettings} = questionStore() const {listQuestions, updateQuestionsList, createQuestion, removeQuestion, openedModalSettings, createOpenedModalSettings} = questionStore()
const idQuestions = listQuestions[params].id
const openedModal = () => { const openedModal = () => {
createOpenedModalSettings({openedModalSettings: "открыто"}) createOpenedModalSettings({openedModalSettings: "open"})
console.log(openedModalSettings) console.log(openedModalSettings)
} }
const theme = useTheme(); const theme = useTheme();

@ -21,14 +21,18 @@ import { useState } from "react";
import DeleteIcon from "@icons/questionsPage/deleteIcon"; import DeleteIcon from "@icons/questionsPage/deleteIcon";
import RadioCheck from "@ui_kit/RadioCheck"; import RadioCheck from "@ui_kit/RadioCheck";
import RadioIcon from "@ui_kit/RadioIcon"; import RadioIcon from "@ui_kit/RadioIcon";
import {questionStore} from "@root/questions";
export default function BranchingQuestions() { export default function BranchingQuestions() {
const theme = useTheme(); const {listQuestions, updateQuestionsList, createQuestion, removeQuestion, openedModalSettings, createOpenedModalSettings} = questionStore()
const [open, setOpen] = useState(false); const theme = useTheme();
const [condition, setCondition] = useState<boolean>(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const [condition, setCondition] = useState<boolean>(false);
const handleClose = () => {
createOpenedModalSettings({openedModalSettings: ""})
console.log(openedModalSettings)
}
const [display, setDisplay] = React.useState("1"); const [display, setDisplay] = React.useState("1");
const handleChange = (event: SelectChangeEvent) => { const handleChange = (event: SelectChangeEvent) => {
setDisplay(event.target.value); setDisplay(event.target.value);
@ -42,7 +46,7 @@ export default function BranchingQuestions() {
return ( return (
<> <>
<Modal <Modal
open={open} open={Boolean(openedModalSettings)}
onClose={handleClose} onClose={handleClose}
aria-labelledby="modal-modal-title" aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description" aria-describedby="modal-modal-description"

@ -115,12 +115,6 @@ export default function StartPageSettings({ handleNext }: HandleNext) {
return ( return (
<> <>
<DropFav
text="a"
sx={{}}
heightImg="100"
widthImg="200"
/>
<Typography variant="h5" sx={{marginTop: "60px"}}>Стартовая страница</Typography> <Typography variant="h5" sx={{marginTop: "60px"}}>Стартовая страница</Typography>
<Box sx={{ <Box sx={{
backgroundColor: "white", backgroundColor: "white",
@ -384,7 +378,7 @@ export default function StartPageSettings({ handleNext }: HandleNext) {
alignItems: "end", alignItems: "end",
gap: "10px", gap: "10px",
}}> }}>
<DropZone sx={{height: "48px", width: "48px"}} heightImg={"48px"} widthImg={"48px"}/> <DropFav sx={{height: "48px", width: "48px"}} heightImg={"48px"} widthImg={"48px"}/>
<Typography sx={{ <Typography sx={{
color: theme.palette.orange.main, color: theme.palette.orange.main,
@ -393,7 +387,7 @@ export default function StartPageSettings({ handleNext }: HandleNext) {
textDecoration: "underline", textDecoration: "underline",
}}>5 MB максимум</Typography> }}>5 MB максимум</Typography>
</Box> </Box>
{/*<DropFav heightImg={"200px"}/>*/}
</Box> </Box>
{/*Правая сторона*/} {/*Правая сторона*/}
<Box sx={{ <Box sx={{

@ -20,9 +20,6 @@ const imageFavicon = [
compressFormat: "PNG", compressFormat: "PNG",
quality: 100, quality: 100,
rotation: 0, rotation: 0,
// outputType: "string",
// minWidth: 16,
// minHeight: 16,
}, },
{ {
maxWidth: 32, maxWidth: 32,
@ -30,9 +27,6 @@ const imageFavicon = [
compressFormat: "PNG", compressFormat: "PNG",
quality: 100, quality: 100,
rotation: 0, rotation: 0,
// outputType: "string",
// minWidth: 32,
// minHeight: 32,
}, },
{ {
maxWidth: 48, maxWidth: 48,
@ -40,9 +34,6 @@ const imageFavicon = [
compressFormat: "PNG", compressFormat: "PNG",
quality: 100, quality: 100,
rotation: 0, rotation: 0,
// outputType: "string",
// minWidth: 48,
// minHeight: 48,
}, },
{ {
maxWidth: 76, maxWidth: 76,

@ -70,12 +70,8 @@ export const questionStore = create<QuestionStore>()(
state[id] = array state[id] = array
set({listQuestions: state}); set({listQuestions: state});
}, },
<<<<<<< HEAD
openedModalSettings: "", openedModalSettings: "",
=======
openedModalSettings: [],
>>>>>>> 12f9f82 (images from favicon)
createOpenedModalSettings: (data:any) => { createOpenedModalSettings: (data:any) => {
const oldState = get() const oldState = get()