если не был дан ответ на вопрос - шлётся пустая строка

This commit is contained in:
Nastya 2024-07-05 20:05:26 +03:00
parent b28f0c840d
commit 481a8681ca
2 changed files with 13 additions and 2 deletions

@ -97,7 +97,7 @@ export default function ViewPublicationPage() {
moveToNextQuestion={() => { moveToNextQuestion={() => {
moveToNextQuestion(); moveToNextQuestion();
if (!currentAnswer || preview) return; if (preview) return;
sendQuestionAnswer(quizId, currentQuestion, currentAnswer)?.catch((e) => { sendQuestionAnswer(quizId, currentQuestion, currentAnswer)?.catch((e) => {
enqueueSnackbar("Ошибка при отправке ответа"); enqueueSnackbar("Ошибка при отправке ответа");

@ -4,7 +4,18 @@ import { QuestionAnswer } from "@/stores/quizView";
import moment from "moment"; import moment from "moment";
import { notReachable } from "./notReachable"; import { notReachable } from "./notReachable";
export function sendQuestionAnswer(quizId: string, question: RealTypedQuizQuestion, questionAnswer: QuestionAnswer) { export function sendQuestionAnswer(
quizId: string,
question: RealTypedQuizQuestion,
questionAnswer: QuestionAnswer | undefined
) {
if (!questionAnswer) {
return sendAnswer({
questionId: question.id,
body: "",
qid: quizId,
});
}
switch (question.type) { switch (question.type) {
case "date": { case "date": {
if (!moment.isMoment(questionAnswer.answer)) throw new Error("Cannot send answer in date question"); if (!moment.isMoment(questionAnswer.answer)) throw new Error("Cannot send answer in date question");