import { Box, IconButton, Typography, useTheme } from "@mui/material"; import { sendAnswer } from "@api/quizRelase"; import { useQuizSettings } from "@contexts/QuizDataContext"; import { useQuizViewStore } from "@stores/quizView"; import CloseBold from "@icons/CloseBold"; import type { QuizQuestionFile } from "@model/questionTypes/file"; import { useTranslation } from "react-i18next"; type UploadedFileProps = { currentQuestion: QuizQuestionFile; setIsSending: (isSending: boolean) => void; }; export const UploadedFile = ({ currentQuestion, setIsSending }: UploadedFileProps) => { const { quizId, preview } = useQuizSettings(); const answers = useQuizViewStore((state) => state.answers); const { updateAnswer } = useQuizViewStore((state) => state); const theme = useTheme(); const { t } = useTranslation(); 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 ( {t("You have uploaded")}: {answer?.split("|")[0]} ); };