Skip to content

Commit

Permalink
refactor: error page UI improvement (closes #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldanielecki committed Jan 13, 2025
1 parent e70943a commit f411cad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
15 changes: 15 additions & 0 deletions components/ExamQuizForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ const ExamQuizForm: FC<Props> = ({
};

if (isLoading) return <LoadingIndicator />;

if (!questionSet) {
handleNextQuestion(1);
return (
<div className="flex flex-col items-center justify-center h-full">
<p className="text-red-500 text-lg font-semibold">
Oops! Something went wrong while loading the questions.
</p>
<p className="text-white text-md mt-2">
Please try refreshing the page or check your internet connection.
</p>
</div>
);
}

const { question, options } = questionSet;

const noOfAnswers = options.filter((el) => el.isAnswer).length;
Expand Down
12 changes: 10 additions & 2 deletions components/QuizForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,18 @@ const QuizForm: FC<Props> = ({

if (isLoading) return <LoadingIndicator />;

//Error Handling for loading issues
if (!questionSet) {
handleNextQuestion(1);
return <p>Loading questions failed.</p>;
return (
<div className="flex flex-col items-center justify-center h-full">
<p className="text-red-500 text-lg font-semibold">
Oops! Something went wrong while loading the questions.
</p>
<p className="text-white text-md mt-2">
Please try refreshing the page or check your internet connection.
</p>
</div>
);
}

const { question, options, images } = questionSet!;
Expand Down

0 comments on commit f411cad

Please sign in to comment.