import {Box, Typography, ButtonBase, useTheme, IconButton} from "@mui/material"; import { useQuizViewStore, updateAnswer } from "@root/quizView"; import { UPLOAD_FILE_TYPES_MAP } from "@ui_kit/QuizPreview/QuizPreviewQuestionTypes/File"; import UploadIcon from "@icons/UploadIcon"; import X from "@icons/CloseBold"; import type { ChangeEvent } from "react"; import type { QuizQuestionFile } from "../../../model/questionTypes/file"; import {DragEvent} from "react"; type FileProps = { currentQuestion: QuizQuestionFile; }; export const File = ({ currentQuestion }: FileProps) => { const { answers } = useQuizViewStore(); const answer = answers.find( ({ questionId }) => questionId === currentQuestion.content.id )?.answer as string; const theme = useTheme(); const uploadFile = ({ target }: ChangeEvent) => { const file = target.files?.[0]; if (file) { updateAnswer( currentQuestion.content.id, `${file.name}|${URL.createObjectURL(file)}` ); } }; return ( {currentQuestion.title} {answer?.split("|")[0] && ( Вы загрузили: {answer?.split("|")[0]} {updateAnswer(currentQuestion.content.id, "");}} > )} {!answer?.split("|")[0] && ( ) => event.preventDefault()} sx={{ width: "100%", height: "120px", display: "flex", justifyContent: "space-between", alignItems: "center", padding: "33px 44px 33px 55px", backgroundColor: theme.palette.background.default, border: `1px solid ${theme.palette.grey2.main}`, borderRadius: "8px", }} > Добавить видео Принимает .mp4 и .mov формат — максимум 100мб )} {answer && currentQuestion.content.type === "picture" && ( )} {answer && currentQuestion.content.type === "video" && ( ); };