2023-09-21 10:07:30 +00:00
|
|
|
|
import { useState } from "react";
|
2023-09-06 13:20:12 +00:00
|
|
|
|
import { useParams } from "react-router-dom";
|
2023-09-25 07:12:22 +00:00
|
|
|
|
import { Box, Link, Typography, useMediaQuery, useTheme } from "@mui/material";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import ButtonsOptions from "../ButtonsOptions";
|
|
|
|
|
import SwitchEmoji from "./switchEmoji";
|
2023-09-06 07:30:27 +00:00
|
|
|
|
import { AnswerDraggableList } from "../AnswerDraggableList";
|
|
|
|
|
import { questionStore, updateQuestionsList } from "@root/questions";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
|
2023-10-02 19:43:07 +00:00
|
|
|
|
import type { QuizQuestionEmoji } from "../../../model/questionTypes/emoji";
|
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
interface Props {
|
|
|
|
|
totalIndex: number;
|
|
|
|
|
}
|
2023-10-02 19:43:07 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
export default function Emoji({ totalIndex }: Props) {
|
2023-09-21 10:07:30 +00:00
|
|
|
|
const [switchState, setSwitchState] = useState<string>("setting");
|
2023-09-06 07:30:27 +00:00
|
|
|
|
const { listQuestions } = questionStore();
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const quizId = Number(useParams().quizId);
|
2023-09-06 07:30:27 +00:00
|
|
|
|
const theme = useTheme();
|
2023-09-15 12:37:12 +00:00
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
2023-10-02 19:43:07 +00:00
|
|
|
|
const question = listQuestions[quizId][totalIndex] as QuizQuestionEmoji;
|
2023-09-06 07:30:27 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
const SSHC = (data: string) => {
|
|
|
|
|
setSwitchState(data);
|
|
|
|
|
};
|
2023-09-06 07:30:27 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Box sx={{ padding: "20px" }}>
|
2023-09-25 07:12:22 +00:00
|
|
|
|
<AnswerDraggableList
|
2023-10-02 19:43:07 +00:00
|
|
|
|
variants={question.content.variants}
|
2023-09-25 07:12:22 +00:00
|
|
|
|
totalIndex={totalIndex}
|
|
|
|
|
emoji
|
|
|
|
|
/>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
<Box sx={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
|
|
|
|
<Link
|
|
|
|
|
component="button"
|
|
|
|
|
variant="body2"
|
|
|
|
|
sx={{ color: theme.palette.brightPurple.main }}
|
2023-09-06 07:30:27 +00:00
|
|
|
|
onClick={() => {
|
2023-10-02 19:43:07 +00:00
|
|
|
|
const answerNew = question.content.variants.slice();
|
2023-10-03 14:03:57 +00:00
|
|
|
|
answerNew.push({ answer: "", hints: "", extendedText: "" });
|
2023-09-06 07:30:27 +00:00
|
|
|
|
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
2023-10-04 09:45:51 +00:00
|
|
|
|
content: { ...question.content, variants: answerNew },
|
2023-09-06 07:30:27 +00:00
|
|
|
|
});
|
|
|
|
|
}}
|
2023-08-24 11:09:47 +00:00
|
|
|
|
>
|
|
|
|
|
Добавьте ответ
|
|
|
|
|
</Link>
|
2023-09-15 12:37:12 +00:00
|
|
|
|
{isMobile ? null : (
|
|
|
|
|
<>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
lineHeight: "21.33px",
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
или нажмите Enter
|
|
|
|
|
</Typography>
|
|
|
|
|
<EnterIcon />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2023-08-24 11:09:47 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2023-09-21 10:07:30 +00:00
|
|
|
|
<ButtonsOptions
|
|
|
|
|
switchState={switchState}
|
|
|
|
|
SSHC={SSHC}
|
|
|
|
|
totalIndex={totalIndex}
|
|
|
|
|
/>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
<SwitchEmoji switchState={switchState} totalIndex={totalIndex} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
2023-06-30 14:39:07 +00:00
|
|
|
|
}
|