import { Box, IconButton, Typography, useTheme } from "@mui/material"; import { sendAnswer } from "@api/quizRelase"; import { useQuizData } from "@contexts/QuizDataContext"; import { useQuizViewStore } from "@stores/quizView"; import CloseBold from "@icons/CloseBold"; import type { QuizQuestionFile } from "@model/questionTypes/file"; type UploadedFileProps = { currentQuestion: QuizQuestionFile; setIsSending: (isSending: boolean) => void; }; export const UploadedFile = ({ currentQuestion, setIsSending, }: UploadedFileProps) => { const { quizId, preview } = useQuizData(); const answers = useQuizViewStore((state) => state.answers); const { updateAnswer } = useQuizViewStore((state) => state); const theme = useTheme(); const answer = answers.find( ({ questionId }) => questionId === currentQuestion.id )?.answer as string; const deleteFile = async () => { if (answer.length > 0) { setIsSending(true); await sendAnswer({ questionId: currentQuestion.id, body: "", qid: quizId, preview, }); } updateAnswer(currentQuestion.id, "", 0); setIsSending(false); }; return ( Вы загрузили: {answer?.split("|")[0]} ); };