Skip to content

Commit f411cad

Browse files
refactor: error page UI improvement (closes #15)
1 parent e70943a commit f411cad

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

components/ExamQuizForm.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ const ExamQuizForm: FC<Props> = ({
3737
};
3838

3939
if (isLoading) return <LoadingIndicator />;
40+
41+
if (!questionSet) {
42+
handleNextQuestion(1);
43+
return (
44+
<div className="flex flex-col items-center justify-center h-full">
45+
<p className="text-red-500 text-lg font-semibold">
46+
Oops! Something went wrong while loading the questions.
47+
</p>
48+
<p className="text-white text-md mt-2">
49+
Please try refreshing the page or check your internet connection.
50+
</p>
51+
</div>
52+
);
53+
}
54+
4055
const { question, options } = questionSet;
4156

4257
const noOfAnswers = options.filter((el) => el.isAnswer).length;

components/QuizForm.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,18 @@ const QuizForm: FC<Props> = ({
123123

124124
if (isLoading) return <LoadingIndicator />;
125125

126-
//Error Handling for loading issues
127126
if (!questionSet) {
128127
handleNextQuestion(1);
129-
return <p>Loading questions failed.</p>;
128+
return (
129+
<div className="flex flex-col items-center justify-center h-full">
130+
<p className="text-red-500 text-lg font-semibold">
131+
Oops! Something went wrong while loading the questions.
132+
</p>
133+
<p className="text-white text-md mt-2">
134+
Please try refreshing the page or check your internet connection.
135+
</p>
136+
</div>
137+
);
130138
}
131139

132140
const { question, options, images } = questionSet!;

0 commit comments

Comments
 (0)