import { Box, Typography, Link, useTheme, TextField, FormControl, InputAdornment, IconButton, } from "@mui/material"; import React, { useState } from "react"; import EnterIcon from "../../../assets/icons/questionsPage/enterIcon"; import SwitchAnswerOptions from "./switchAnswerOptions"; import ButtonsOptionsAndPict from "../ButtonsOptionsAndPict"; import QuestionsPageCard from "../DraggableList/QuestionPageCard"; import { useParams } from "react-router-dom"; import { Variants, questionStore, updateQuestionsList } from "@root/questions"; import PointsIcon from "@icons/questionsPage/PointsIcon"; import DeleteIcon from "@icons/questionsPage/deleteIcon"; import MessageIcon from "@icons/messagIcon"; import Popover from "@mui/material/Popover"; import TextareaAutosize from "@mui/base/TextareaAutosize"; // Импортируем интерфейс Varian interface Props { totalIndex: number; } export default function AnswerOptions({ totalIndex }: Props) { const { listQuestions } = questionStore(); const Answer = listQuestions[totalIndex].content.variants; console.log(Answer); const theme = useTheme(); const [switchState, setSwitchState] = React.useState("setting"); const SSHC = (data: string) => { setSwitchState(data); }; const [isOpen, setIsOpen] = React.useState(false); const [anchorEl, setAnchorEl] = React.useState( null ); const handleClick = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); setIsOpen(true); }; const handleClose = () => { setIsOpen(false); }; const id = "my-popover-id"; return ( <> {Answer.length === 0 ? ( Добавьте ответ ) : ( {Answer.map((variant: Variants, index: number) => ( { const answerNew = Answer.slice(); // Create a shallow copy of the array answerNew[index].answer = e.target.value; let clonContent = listQuestions[totalIndex].content; clonContent.variants = answerNew; updateQuestionsList(totalIndex, { content: clonContent }); }} InputProps={{ startAdornment: ( ), endAdornment: ( { const answerNew = Answer.slice(); // Create a shallow copy of the array answerNew[index].hints = e.target.value; let clonContent = listQuestions[totalIndex].content; clonContent.variants = answerNew; updateQuestionsList(totalIndex, { content: clonContent, }); }} /> { const answerNew = Answer.slice(); // Create a shallow copy of the array answerNew.splice(index, 1); let clonContent = listQuestions[totalIndex].content; clonContent.variants = answerNew; updateQuestionsList(totalIndex, { content: clonContent, }); }} > ), }} sx={{ "& .MuiInputBase-root": { height: "48px", borderRadius: "10px", }, }} inputProps={{ sx: { borderRadius: "10px", fontSize: "18px", lineHeight: "21px", py: 0, }, }} /> ))} )} { const answerNew = Answer.slice(); // Create a shallow copy of the array answerNew.push({ answer: "", answerLong: "", hints: "", }); let clonContent = listQuestions[totalIndex].content; clonContent.variants = answerNew; updateQuestionsList(totalIndex, { content: clonContent }); }} > Добавьте ответ или нажмите Enter ); }