2023-09-27 14:14:48 +00:00
|
|
|
|
import { useState, useEffect } from "react";
|
2023-03-30 18:39:59 +00:00
|
|
|
|
import MiniButtonSetting from "@ui_kit/MiniButtonSetting";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import SettingIcon from "../../assets/icons/questionsPage/settingIcon";
|
|
|
|
|
import Clue from "../../assets/icons/questionsPage/clue";
|
|
|
|
|
import Branching from "../../assets/icons/questionsPage/branching";
|
2023-09-18 10:22:09 +00:00
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
IconButton,
|
|
|
|
|
Tooltip,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
|
|
|
|
} from "@mui/material";
|
2023-09-25 13:43:15 +00:00
|
|
|
|
import { HideIcon } from "../../assets/icons/questionsPage/hideIcon";
|
|
|
|
|
import { CopyIcon } from "../../assets/icons/questionsPage/CopyIcon";
|
|
|
|
|
import { DeleteIcon } from "../../assets/icons/questionsPage/deleteIcon";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import ImgIcon from "../../assets/icons/questionsPage/imgIcon";
|
2023-08-16 13:29:28 +00:00
|
|
|
|
import { useParams } from "react-router-dom";
|
2023-10-13 09:09:28 +00:00
|
|
|
|
import { quizStore } from "@root/quizes";
|
2023-09-18 10:22:09 +00:00
|
|
|
|
import {
|
|
|
|
|
questionStore,
|
|
|
|
|
copyQuestion,
|
|
|
|
|
removeQuestion,
|
|
|
|
|
resetSomeField,
|
2023-09-27 14:14:48 +00:00
|
|
|
|
removeQuestionForce,
|
|
|
|
|
updateQuestionsList,
|
2023-09-18 10:22:09 +00:00
|
|
|
|
} from "@root/questions";
|
2023-09-21 07:00:08 +00:00
|
|
|
|
import { DoubleArrowRight } from "@icons/questionsPage/DoubleArrowRight";
|
|
|
|
|
import { DoubleTick } from "@icons/questionsPage/DoubleTick";
|
|
|
|
|
import { VectorQuestions } from "@icons/questionsPage/VectorQuestions";
|
|
|
|
|
import { ReallyChangingModal } from "@ui_kit/Modal/ReallyChangingModal/ReallyChangingModal";
|
|
|
|
|
|
2023-10-05 14:03:54 +00:00
|
|
|
|
import type { QuizQuestionBase } from "../../model/questionTypes/shared";
|
|
|
|
|
|
2023-03-30 18:39:59 +00:00
|
|
|
|
interface Props {
|
2023-04-15 09:10:59 +00:00
|
|
|
|
switchState: string;
|
|
|
|
|
SSHC: (data: string) => void;
|
2023-08-16 13:29:28 +00:00
|
|
|
|
totalIndex: number;
|
2023-03-30 18:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-18 10:22:09 +00:00
|
|
|
|
export default function ButtonsOptionsAndPict({
|
|
|
|
|
SSHC,
|
|
|
|
|
switchState,
|
|
|
|
|
totalIndex,
|
|
|
|
|
}: Props) {
|
|
|
|
|
const [buttonHover, setButtonHover] = useState<string>("");
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const quizId = Number(useParams().quizId);
|
2023-10-13 09:09:28 +00:00
|
|
|
|
const { listQuizes } = quizStore();
|
2023-09-27 14:14:48 +00:00
|
|
|
|
const { listQuestions } = questionStore();
|
|
|
|
|
const [openedReallyChangingModal, setOpenedReallyChangingModal] =
|
|
|
|
|
useState<boolean>(false);
|
2023-04-15 09:10:59 +00:00
|
|
|
|
const theme = useTheme();
|
2023-09-15 12:37:12 +00:00
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
2023-09-21 07:00:08 +00:00
|
|
|
|
const isIconMobile = useMediaQuery(theme.breakpoints.down(1050));
|
2023-10-13 09:09:28 +00:00
|
|
|
|
const quize = listQuizes[quizId];
|
2023-10-05 14:03:54 +00:00
|
|
|
|
const question = listQuestions[quizId][totalIndex] as QuizQuestionBase;
|
2023-08-16 13:29:28 +00:00
|
|
|
|
|
2023-09-27 14:14:48 +00:00
|
|
|
|
useEffect(() => {
|
2023-10-05 14:03:54 +00:00
|
|
|
|
if (question.deleteTimeoutId) {
|
|
|
|
|
clearTimeout(question.deleteTimeoutId);
|
2023-09-27 14:14:48 +00:00
|
|
|
|
}
|
|
|
|
|
}, [listQuestions]);
|
2023-08-16 13:29:28 +00:00
|
|
|
|
|
|
|
|
|
const openedModal = () => {
|
|
|
|
|
resetSomeField({ openedModalSettings: "open" });
|
|
|
|
|
};
|
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
alignItems: "center",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
width: "100%",
|
|
|
|
|
background: "#f2f3f7",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
height: isMobile ? "92px" : "70px",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
2023-09-25 13:43:15 +00:00
|
|
|
|
padding: isMobile ? " 3px 12px 11px" : "20px",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
display: "flex",
|
2023-09-15 12:37:12 +00:00
|
|
|
|
flexWrap: isMobile ? "wrap" : "nowrap",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
gap: "6px",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<MiniButtonSetting
|
2023-09-18 10:22:09 +00:00
|
|
|
|
onMouseEnter={() => setButtonHover("setting")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
onClick={() => {
|
|
|
|
|
SSHC("setting");
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
2023-09-25 13:43:15 +00:00
|
|
|
|
maxWidth: "104px",
|
2023-09-15 12:37:12 +00:00
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
|
|
|
|
height: "30px",
|
2023-09-18 10:22:09 +00:00
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "setting"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
switchState === "setting" ? "#ffffff" : theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color:
|
|
|
|
|
switchState === "setting" ? theme.palette.grey3.main : null,
|
|
|
|
|
},
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-18 10:22:09 +00:00
|
|
|
|
<SettingIcon
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "setting"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "setting"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
{isIconMobile ? null : "Настройки"}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
2023-09-18 10:22:09 +00:00
|
|
|
|
onMouseEnter={() => setButtonHover("help")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
onClick={() => {
|
|
|
|
|
SSHC("help");
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
2023-09-15 12:37:12 +00:00
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
maxWidth: "102px",
|
2023-09-15 12:37:12 +00:00
|
|
|
|
height: "30px",
|
2023-09-18 10:22:09 +00:00
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "help"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
switchState === "help" ? "#ffffff" : theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color: switchState === "help" ? theme.palette.grey3.main : null,
|
|
|
|
|
},
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-18 10:22:09 +00:00
|
|
|
|
<Clue
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "help"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "help"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
{isIconMobile ? null : "Подсказка"}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</MiniButtonSetting>
|
2023-10-13 09:09:28 +00:00
|
|
|
|
{quize.config.type === "quize" && (
|
|
|
|
|
<>
|
|
|
|
|
<Tooltip
|
|
|
|
|
arrow
|
|
|
|
|
placement="right"
|
|
|
|
|
componentsProps={{
|
|
|
|
|
tooltip: {
|
|
|
|
|
sx: {
|
|
|
|
|
background: "#fff",
|
|
|
|
|
borderRadius: "6px",
|
|
|
|
|
color: "#9A9AAF",
|
|
|
|
|
boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)",
|
|
|
|
|
"& .MuiTooltip-arrow": {
|
|
|
|
|
color: "#FFF",
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-10-12 15:51:39 +00:00
|
|
|
|
},
|
2023-10-13 09:09:28 +00:00
|
|
|
|
}}
|
|
|
|
|
title={
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
color: "#4D4D4D",
|
|
|
|
|
fontWeight: "bold",
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
marginBottom: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Будет показан при условии
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{ fontWeight: "bold", fontSize: "12px" }}>
|
|
|
|
|
Название
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: "bold",
|
|
|
|
|
fontSize: "12px",
|
|
|
|
|
marginBottom: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Условие 1, Условие 2
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{ color: "#7E2AEA", fontSize: "12px" }}>
|
|
|
|
|
Все условия обязательны
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onMouseEnter={() => setButtonHover("branching")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
SSHC("branching");
|
|
|
|
|
openedModal();
|
2023-08-16 13:29:28 +00:00
|
|
|
|
}}
|
|
|
|
|
sx={{
|
2023-10-13 09:09:28 +00:00
|
|
|
|
height: "30px",
|
|
|
|
|
maxWidth: "103px",
|
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "branching"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
switchState === "branching"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color:
|
|
|
|
|
switchState === "branching"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: null,
|
|
|
|
|
},
|
2023-08-16 13:29:28 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-10-13 09:09:28 +00:00
|
|
|
|
<Branching
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "branching"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "branching"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{isIconMobile ? null : "Ветвление"}
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onMouseEnter={() => setButtonHover("image")}
|
|
|
|
|
onMouseLeave={() => setButtonHover("")}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
SSHC("image");
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
height: "30px",
|
|
|
|
|
maxWidth: "123px",
|
|
|
|
|
minWidth: isIconMobile ? "30px" : "64px",
|
|
|
|
|
backgroundColor:
|
|
|
|
|
switchState === "image"
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
2023-09-18 10:22:09 +00:00
|
|
|
|
color:
|
2023-10-13 09:09:28 +00:00
|
|
|
|
switchState === "image"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main,
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color:
|
|
|
|
|
switchState === "image" ? theme.palette.grey3.main : null,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ImgIcon
|
|
|
|
|
color={
|
|
|
|
|
buttonHover === "image"
|
|
|
|
|
? theme.palette.grey3.main
|
|
|
|
|
: switchState === "image"
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{isIconMobile ? null : "Изображение"}
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onClick={() => setOpenedReallyChangingModal(true)}
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: "30px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor: "#FEDFD0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<DoubleTick style={{ color: "#FC712F", fontSize: "9px" }} />
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onClick={() => setOpenedReallyChangingModal(true)}
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: "30px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor: "#FEDFD0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<DoubleArrowRight style={{ color: "#FC712F", fontSize: "9px" }} />
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
<MiniButtonSetting
|
|
|
|
|
onClick={() => setOpenedReallyChangingModal(true)}
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: "30px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
backgroundColor: "#FEDFD0",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<VectorQuestions style={{ color: "#FC712F", fontSize: "9px" }} />
|
|
|
|
|
</MiniButtonSetting>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<IconButton sx={{ borderRadius: "6px", padding: "0px 2px" }}>
|
|
|
|
|
<HideIcon style={{ color: "#4D4D4D" }} />
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</IconButton>
|
2023-09-18 10:22:09 +00:00
|
|
|
|
<IconButton
|
2023-10-05 14:03:54 +00:00
|
|
|
|
sx={{ borderRadius: "6px" }}
|
|
|
|
|
onClick={() => copyQuestion(quizId, totalIndex)}
|
|
|
|
|
>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<CopyIcon style={{ color: "#4D4D4D" }} />
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</IconButton>
|
2023-09-18 10:22:09 +00:00
|
|
|
|
<IconButton
|
|
|
|
|
sx={{ borderRadius: "6px", padding: "2px" }}
|
2023-09-27 14:14:48 +00:00
|
|
|
|
onClick={() => {
|
2023-10-05 14:03:54 +00:00
|
|
|
|
const removedId = question.id;
|
|
|
|
|
if (question.deleteTimeoutId) {
|
|
|
|
|
clearTimeout(question.deleteTimeoutId);
|
2023-09-27 14:14:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
removeQuestion(quizId, totalIndex);
|
|
|
|
|
|
|
|
|
|
const newTimeoutId = window.setTimeout(() => {
|
|
|
|
|
removeQuestionForce(quizId, removedId);
|
|
|
|
|
}, 5000);
|
|
|
|
|
|
2023-10-05 14:03:54 +00:00
|
|
|
|
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
|
|
|
|
|
...question,
|
2023-09-27 14:14:48 +00:00
|
|
|
|
deleteTimeoutId: newTimeoutId,
|
|
|
|
|
});
|
|
|
|
|
}}
|
2023-09-18 10:22:09 +00:00
|
|
|
|
>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<DeleteIcon style={{ color: "#4D4D4D" }} />
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
2023-09-27 14:14:48 +00:00
|
|
|
|
<ReallyChangingModal
|
|
|
|
|
opened={openedReallyChangingModal}
|
|
|
|
|
onClose={() => setOpenedReallyChangingModal(false)}
|
|
|
|
|
/>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|