import { useParams } from "react-router-dom"; import { Box, Typography, useMediaQuery, useTheme } from "@mui/material"; import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomTextField from "@ui_kit/CustomTextField"; import { useDebouncedCallback } from "use-debounce"; import { questionStore, updateQuestionsList } from "@root/questions"; import InfoIcon from "../../../assets/icons/InfoIcon"; type SettingDropDownProps = { totalIndex: number; }; export default function SettingDropDown({ totalIndex }: SettingDropDownProps) { const quizId = Number(useParams().quizId); const { listQuestions } = questionStore(); const theme = useTheme(); const isTablet = useMediaQuery(theme.breakpoints.down(1000)); const isMobile = useMediaQuery(theme.breakpoints.down(790)); const debounced = useDebouncedCallback((value) => { let clonContent = listQuestions[quizId][totalIndex].content; clonContent.innerName = value; updateQuestionsList(quizId, totalIndex, { content: clonContent }); }, 1000); const debounceAnswer = useDebouncedCallback((value) => { const clonContent = listQuestions[quizId][totalIndex].content; clonContent.default = value; updateQuestionsList(quizId, totalIndex, { content: clonContent }); }, 1000); return ( <> Настройки ответов updateQuestionsList(quizId, totalIndex, { content: { ...listQuestions[quizId][totalIndex].content, multi: target.checked, }, }) } /> Текст в выпадающем списке debounceAnswer(target.value)} /> Настройки вопросов { updateQuestionsList(quizId, totalIndex, { required: !e.target.checked, }); }} /> { let clonContent = listQuestions[quizId][totalIndex].content; clonContent.innerNameCheck = e.target.checked; if (!e.target.checked) { clonContent.innerName = ""; } updateQuestionsList(quizId, totalIndex, { content: clonContent, }); }} /> Текст в выпадающем списке debounceAnswer(target.value)} /> {listQuestions[quizId][totalIndex].content.innerNameCheck && ( debounced(target.value)} /> )} ); }