import { Box, Typography } from "@mui/material"; import { Select as SelectComponent } from "../tools//Select"; import { useQuizViewStore, updateAnswer, deleteAnswer } from "@root/quizView/store"; import type { QuizQuestionSelect } from "../../../model/questionTypes/select"; import { enqueueSnackbar } from "notistack"; import { sendAnswer } from "@api/quizRelase"; import { useQuestionsStore } from "@root/quizData/store" type SelectProps = { currentQuestion: QuizQuestionSelect; }; export const Select = ({ currentQuestion }: SelectProps) => { const { settings } = useQuestionsStore() const { answers } = useQuizViewStore(); const { answer } = answers.find( ({ questionId }) => questionId === currentQuestion.id ) ?? {}; return ( {currentQuestion.title} answer)} onChange={async(_, value) => { if (value < 0) { deleteAnswer(currentQuestion.id); return; } try { await sendAnswer({ questionId: currentQuestion.id, body: String(value), //@ts-ignore qid: settings.qid }) updateAnswer(currentQuestion.id, String(value)); } catch (e) { enqueueSnackbar("ответ не был засчитан") } }} /> ); };