2023-09-05 13:54:41 +00:00
|
|
|
|
import { useState } from "react";
|
2023-09-06 13:20:12 +00:00
|
|
|
|
import { useParams } from "react-router-dom";
|
2023-04-15 09:10:59 +00:00
|
|
|
|
import { Box, Typography, useTheme } from "@mui/material";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import ButtonsOptions from "../ButtonsOptions";
|
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import AddImage from "../../../assets/icons/questionsPage/addImage";
|
|
|
|
|
import AddVideofile from "../../../assets/icons/questionsPage/addVideofile";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import SwitchPageOptions from "./switchPageOptions";
|
2023-09-05 13:54:41 +00:00
|
|
|
|
import { questionStore, updateQuestionsList } from "@root/questions";
|
|
|
|
|
import { UploadImageModal } from "../UploadImage/UploadImageModal";
|
|
|
|
|
import { UploadVideoModal } from "../UploadVideoModal";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
type Props = {
|
|
|
|
|
disableInput?: boolean;
|
2023-08-12 08:31:21 +00:00
|
|
|
|
totalIndex: number;
|
2023-04-15 09:10:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-06-30 14:39:07 +00:00
|
|
|
|
export default function PageOptions({ disableInput, totalIndex }: Props) {
|
2023-09-05 13:54:41 +00:00
|
|
|
|
const [openImageModal, setOpenImageModal] = useState<boolean>(false);
|
|
|
|
|
const [openVideoModal, setOpenVideoModal] = useState<boolean>(false);
|
|
|
|
|
const [switchState, setSwitchState] = useState("setting");
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const quizId = Number(useParams().quizId);
|
2023-09-05 13:54:41 +00:00
|
|
|
|
const { listQuestions } = questionStore();
|
2023-04-15 09:10:59 +00:00
|
|
|
|
const theme = useTheme();
|
2023-09-05 13:54:41 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
const SSHC = (data: string) => {
|
|
|
|
|
setSwitchState(data);
|
|
|
|
|
};
|
2023-09-05 13:54:41 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "640px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
padding: "20px",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ display: disableInput ? "none" : "" }}>
|
2023-09-05 13:54:41 +00:00
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"Можно добавить текст"}
|
2023-09-06 13:20:12 +00:00
|
|
|
|
text={listQuestions[quizId][totalIndex].content.text}
|
2023-09-05 13:54:41 +00:00
|
|
|
|
onChange={({ target }) => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-09-05 13:54:41 +00:00
|
|
|
|
clonContent.text = target.value;
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, { content: clonContent });
|
2023-09-05 13:54:41 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{ display: "flex", alignItems: "center", gap: "12px" }}>
|
2023-09-05 13:54:41 +00:00
|
|
|
|
<Box
|
|
|
|
|
onClick={() => setOpenImageModal(true)}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
sx={{
|
2023-09-05 13:54:41 +00:00
|
|
|
|
cursor: "pointer",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "10px",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-05 13:54:41 +00:00
|
|
|
|
<AddImage />
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
lineHeight: "18.96px",
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Изображение
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<UploadImageModal
|
|
|
|
|
open={openImageModal}
|
|
|
|
|
onClose={() => setOpenImageModal(false)}
|
|
|
|
|
imgHC={(fileList) => {
|
|
|
|
|
if (fileList?.length) {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-09-05 13:54:41 +00:00
|
|
|
|
clonContent.picture = URL.createObjectURL(fileList[0]);
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: clonContent,
|
|
|
|
|
});
|
2023-09-05 13:54:41 +00:00
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
<Typography> или</Typography>
|
2023-09-05 13:54:41 +00:00
|
|
|
|
<Box
|
|
|
|
|
onClick={() => setOpenVideoModal(true)}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
sx={{
|
2023-09-05 13:54:41 +00:00
|
|
|
|
cursor: "pointer",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "10px",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-05 13:54:41 +00:00
|
|
|
|
<AddVideofile />
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
lineHeight: "18.96px",
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Видео
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<UploadVideoModal
|
|
|
|
|
open={openVideoModal}
|
|
|
|
|
onClose={() => setOpenVideoModal(false)}
|
2023-09-06 13:20:12 +00:00
|
|
|
|
video={listQuestions[quizId][totalIndex].content.video}
|
2023-09-05 13:54:41 +00:00
|
|
|
|
onUpload={(url) => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-09-05 13:54:41 +00:00
|
|
|
|
clonContent.video = url;
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, { content: clonContent });
|
2023-09-05 13:54:41 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
<ButtonsOptions
|
|
|
|
|
switchState={switchState}
|
|
|
|
|
SSHC={SSHC}
|
|
|
|
|
totalIndex={totalIndex}
|
|
|
|
|
/>
|
|
|
|
|
<SwitchPageOptions switchState={switchState} totalIndex={totalIndex} />
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|