import { useState } from "react"; import { useParams } from "react-router-dom"; import { Box, Typography, useMediaQuery, useTheme } from "@mui/material"; import { useDebouncedCallback } from "use-debounce"; import ButtonsOptions from "../ButtonsOptions"; import CustomTextField from "@ui_kit/CustomTextField"; import AddImage from "../../../assets/icons/questionsPage/addImage"; import AddVideofile from "../../../assets/icons/questionsPage/addVideofile"; import SwitchPageOptions from "./switchPageOptions"; import { questionStore, updateQuestionsList } from "@root/questions"; import { UploadImageModal } from "../UploadImage/UploadImageModal"; import { UploadVideoModal } from "../UploadVideoModal"; import { AddPlusImage } from "@icons/questionsPage/addPlusImage"; import { AddPlusVideo } from "@icons/questionsPage/addPlusVideo"; import { ImageAddIcons } from "@icons/ImageAddIcons"; import { VideofileIcon } from "@icons/questionsPage/VideofileIcon"; type Props = { disableInput?: boolean; totalIndex: number; }; export default function PageOptions({ disableInput, totalIndex }: Props) { const [openImageModal, setOpenImageModal] = useState(false); const [openVideoModal, setOpenVideoModal] = useState(false); const [switchState, setSwitchState] = useState("setting"); const quizId = Number(useParams().quizId); const { listQuestions } = questionStore(); const theme = useTheme(); const isTablet = useMediaQuery(theme.breakpoints.down(980)); const isMobile = useMediaQuery(theme.breakpoints.down(780)); const debounced = useDebouncedCallback((value) => { const clonContent = listQuestions[quizId][totalIndex].content; clonContent.text = value; updateQuestionsList(quizId, totalIndex, { content: clonContent }); }, 1000); const SSHC = (data: string) => { setSwitchState(data); }; return ( <> debounced(target.value)} /> setOpenImageModal(true)} sx={{ cursor: "pointer", display: "flex", alignItems: "center", gap: "10px", }} > {isMobile ? ( ) : ( + )} Изображение setOpenImageModal(false)} imgHC={(fileList) => { if (fileList?.length) { const clonContent = listQuestions[quizId][totalIndex].content; clonContent.picture = URL.createObjectURL(fileList[0]); updateQuestionsList(quizId, totalIndex, { content: clonContent, }); } }} // onClick={() => setOpenVideoModal(true)} /> или {isMobile ? ( ) : ( + )} Видео setOpenVideoModal(false)} video={listQuestions[quizId][totalIndex].content.video} onUpload={(url) => { const clonContent = listQuestions[quizId][totalIndex].content; clonContent.video = url; updateQuestionsList(quizId, totalIndex, { content: clonContent }); }} /> ); }