import { useState } from "react"; import { useParams } from "react-router-dom"; import { Box, Typography, useTheme } from "@mui/material"; import ButtonsOptions from "../ButtonsOptions"; import RatingStar from "../../../assets/icons/questionsPage/ratingStar"; import SwitchRating from "./switchRating"; import { questionStore, updateQuestionsList } from "@root/questions"; import CustomTextField from "@ui_kit/CustomTextField"; interface Props { totalIndex: number; } export default function RatingOptions({ totalIndex }: Props) { const [switchState, setSwitchState] = useState("setting"); const quizId = Number(useParams().quizId); const { listQuestions } = questionStore(); const theme = useTheme(); const SSHC = (data: string) => { setSwitchState(data); }; return ( <> { updateQuestionsList(quizId, totalIndex, { content: { ...listQuestions[quizId][totalIndex].content, ratingExpanded: true, }, }); }} sx={{ cursor: "pointer", ":hover": { transform: "scale(1.1)", transition: "0.2s", }, }} /> { updateQuestionsList(quizId, totalIndex, { content: { ...listQuestions[quizId][totalIndex].content, ratingExpanded: true, }, }); }} sx={{ cursor: "pointer", ":hover": { transform: "scale(1.1)", transition: "0.2s", }, }} /> Негативно Позитивно {listQuestions[quizId][totalIndex].content.ratingExpanded && (listQuestions[quizId][totalIndex].content.ratingDescription ? ( {listQuestions[quizId][totalIndex].content.ratingDescription} ) : ( { if (key === "Enter") { const currentTarget = target as HTMLInputElement; updateQuestionsList(quizId, totalIndex, { content: { ...listQuestions[quizId][totalIndex].content, ratingDescription: currentTarget.value.substring(0, 20), }, }); } }} onBlur={({ target }) => { updateQuestionsList(quizId, totalIndex, { content: { ...listQuestions[quizId][totalIndex].content, ratingDescription: target.value.substring(0, 20), }, }); }} /> ))} ); }