81 lines
2.5 KiB
TypeScript
81 lines
2.5 KiB
TypeScript
import { useState } from "react";
|
||
import { useParams } from "react-router-dom";
|
||
import { Box, Link, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
|
||
import ButtonsOptions from "../ButtonsOptions";
|
||
import SwitchEmoji from "./switchEmoji";
|
||
import { AnswerDraggableList } from "../AnswerDraggableList";
|
||
import { questionStore, updateQuestionsList } from "@root/questions";
|
||
|
||
import type { QuizQuestionEmoji } from "../../../model/questionTypes/emoji";
|
||
|
||
interface Props {
|
||
totalIndex: number;
|
||
}
|
||
|
||
export default function Emoji({ totalIndex }: Props) {
|
||
const [switchState, setSwitchState] = useState<string>("setting");
|
||
const { listQuestions } = questionStore();
|
||
const quizId = Number(useParams().quizId);
|
||
const theme = useTheme();
|
||
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
||
const question = listQuestions[quizId][totalIndex] as QuizQuestionEmoji;
|
||
|
||
const SSHC = (data: string) => {
|
||
setSwitchState(data);
|
||
};
|
||
|
||
return (
|
||
<>
|
||
<Box sx={{ padding: "20px" }}>
|
||
<AnswerDraggableList
|
||
variants={question.content.variants}
|
||
totalIndex={totalIndex}
|
||
emoji
|
||
/>
|
||
<Box sx={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
||
<Link
|
||
component="button"
|
||
variant="body2"
|
||
sx={{ color: theme.palette.brightPurple.main }}
|
||
onClick={() => {
|
||
const answerNew = question.content.variants.slice();
|
||
answerNew.push({ answer: "", hints: "", extendedText: "" });
|
||
|
||
updateQuestionsList(quizId, totalIndex, {
|
||
content: {
|
||
...listQuestions[quizId][totalIndex].content,
|
||
variants: answerNew,
|
||
},
|
||
});
|
||
}}
|
||
>
|
||
Добавьте ответ
|
||
</Link>
|
||
{isMobile ? null : (
|
||
<>
|
||
<Typography
|
||
sx={{
|
||
fontWeight: 400,
|
||
fontSize: "18px",
|
||
lineHeight: "21.33px",
|
||
color: theme.palette.grey2.main,
|
||
}}
|
||
>
|
||
или нажмите Enter
|
||
</Typography>
|
||
<EnterIcon />
|
||
</>
|
||
)}
|
||
</Box>
|
||
</Box>
|
||
<ButtonsOptions
|
||
switchState={switchState}
|
||
SSHC={SSHC}
|
||
totalIndex={totalIndex}
|
||
/>
|
||
<SwitchEmoji switchState={switchState} totalIndex={totalIndex} />
|
||
</>
|
||
);
|
||
}
|