обработка ошибки пустого квиза

This commit is contained in:
Nastya 2024-08-31 04:57:26 +03:00
parent eb33e495f3
commit 7d5bc54325
2 changed files with 4 additions and 2 deletions

@ -75,11 +75,12 @@ function QuizAnswererInner({
if (isLoading) return <LoadingSkeleton />;
if (error) return <ApologyPage error={error} />;
// if (!data) return <LoadingSkeleton />;
quizSettings ??= data;
if (!quizSettings) return <ApologyPage error={new Error("Quiz data is null")} />;
if (quizSettings.questions.length === 0) return <ApologyPage error={new Error("No questions found")} />;
if (quizSettings.questions.length === 1 && quizSettings?.settings.cfg.noStartPage)
return <ApologyPage error={new Error("Quiz is empty")} />;
// if (quizSettings.questions.length === 1) return <ApologyPage error={new Error("No questions found")} />;
if (!quizId) return <ApologyPage error={new Error("No quiz id")} />;
const quizContainer = (

@ -8,6 +8,7 @@ export const ApologyPage = ({ error }: Props) => {
if (error.response?.data === "quiz is inactive") message = "Квиз не активирован";
if (error.message === "No questions found") message = "Нет созданных вопросов";
if (error.message === "Quiz is empty") message = "Квиз пуст";
if (error.message === "Quiz already completed") message = "Вы уже прошли этот опрос";
if (error.message === "No quiz id") message = "Отсутствует id квиза";
if (error.message === "Quiz data is null") message = "Не были переданы параметры квиза";