import { useParams } from "react-router-dom"; import { Box, Typography, useMediaQuery, useTheme, Tooltip, } 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"; import type { QuizQuestionFile } from "../../../model/questionTypes/file"; type SettingsUploadProps = { totalIndex: number; }; export default function SettingsUpload({ totalIndex }: SettingsUploadProps) { const theme = useTheme(); const quizId = Number(useParams().quizId); const { listQuestions } = questionStore(); const question = listQuestions[quizId][totalIndex] as QuizQuestionFile; const debounced = useDebouncedCallback((value) => { updateQuestionsList(quizId, totalIndex, { content: { ...question.content, innerName: value }, }); }, 1000); const isMobile = useMediaQuery(theme.breakpoints.down(790)); return ( Настройки вопроса { updateQuestionsList(quizId, totalIndex, { content: { ...question.content, autofill: target.checked }, }); }} /> { updateQuestionsList(quizId, totalIndex, { required: !e.target.checked, }); }} /> { updateQuestionsList(quizId, totalIndex, { content: { ...question.content, innerNameCheck: target.checked, innerName: target.checked ? question.content.innerName : "", }, }); }} /> {question.content.innerNameCheck && ( debounced(target.value)} sx={{ paddingRight: "20px" }} /> )} ); }