import { Box, ButtonBase, Typography } from "@mui/material"; import { updateQuestion } from "@root/questions/actions"; import CustomTextField from "@ui_kit/CustomTextField"; import SelectableButton from "@ui_kit/SelectableButton"; import UploadBox from "@ui_kit/UploadBox"; import { memo, useState } from "react"; import UploadIcon from "../../assets/icons/UploadIcon"; import { UploadVideoModal } from "./UploadVideoModal"; type BackgroundType = "text" | "video"; type HelpQuestionsProps = { questionId: string; hintVideo: string; hintText: string; }; const HelpQuestions = memo(function ({ questionId, hintVideo, hintText, }) { const [open, setOpen] = useState(false); const [backgroundType, setBackgroundType] = useState("text"); const updateQuestionHint = (value: string) => { updateQuestion(questionId, (question) => { question.content.hint.text = value; }); }; return ( Подсказка консультанта setBackgroundType("text")} sx={{ maxWidth: "130px" }} > Текст setBackgroundType("video")} sx={{ maxWidth: "130px" }} > Видео {backgroundType === "text" ? ( <> updateQuestionHint(target.value || " ")} maxLength={100} /> ) : ( Загрузите видео setOpen(true)} sx={{ justifyContent: "flex-start" }} > {hintVideo ? ( setOpen(false)} video={hintVideo} onUpload={(url) => updateQuestion(questionId, (question) => { question.content.hint.video = url; }) } /> )} ); }); HelpQuestions.displayName = "HelpQuestions"; export default HelpQuestions;