Skip to content

Commit 1069c0b

Browse files
committed
Add error handling on skips/noises tasks page
1 parent 5b3ad73 commit 1069c0b

3 files changed

Lines changed: 41 additions & 9 deletions

File tree

src/views/AliasPage.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@
7070

7171
<!-- Noises task interface -->
7272
<div v-else-if="taskType === 'noises'">
73-
<div v-if="submissionResult.score === -1 && submissionResult.hints.length === 0" class="no-submissions-message">
73+
<div v-if="!isSubmitting && submissionResult.score === -1 && submissionResult.hints.length === 0" class="no-submissions-message">
7474
No submissions yet. Make your first one!
7575
</div>
76-
<div v-else class="submission-result">
76+
<div v-if="isSubmitting" class="checking-message">
77+
Checking your answer, give us some time...
78+
</div>
79+
<div v-else-if="submissionResult.score !== -1 || submissionResult.hints.length > 0" class="submission-result">
7780
<p class="score">Score: {{ submissionResult.score }}</p>
7881
<div v-if="submissionResult.hints.length" class="hints">
7982
<h4>Hints:</h4>
@@ -323,7 +326,7 @@ const submitAnswers = async () => {
323326
submissionResult.value = {
324327
score: statusData.score,
325328
hints: statusData.hints || [],
326-
message: statusData.score === 100 ? 'Task solved correctly! Score: 100' : `Task not solved correctly. Score: ${statusData.score}`
329+
message: statusData.score === 100 ? 'Task solved correctly!' : `Task not solved correctly. Fix errors and try again.`
327330
}
328331
isSubmitting.value = false
329332
}
@@ -776,6 +779,13 @@ input:checked + .slider:before {
776779
text-align: center;
777780
}
778781
782+
.checking-message {
783+
margin-top: 20px;
784+
text-align: center;
785+
font-size: 1.2em;
786+
color: var(--text-gray);
787+
}
788+
779789
.score {
780790
font-size: 1.2em;
781791
font-weight: 600;

src/views/SolveNoises.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="solve-noises-page-wrapper">
33
<div v-if="loading" class="loading-message">Looking for tasks...</div>
4+
<div v-else-if="noTasks" class="no-tasks-message">No tasks available yet. Create a task and be the first to publish!</div>
45
<div v-else-if="error" class="error-message">{{ error }}</div>
56
<div v-else class="content-container">
67
<h2 class="section-header">Available Noises Tasks</h2>
@@ -36,6 +37,7 @@ const limit = ref(10)
3637
const hasMore = ref(true)
3738
const loadingMore = ref(false)
3839
const loadingRandom = ref(false)
40+
const noTasks = ref(false)
3941
4042
const loadTasks = async () => {
4143
loading.value = true
@@ -49,9 +51,11 @@ const loadTasks = async () => {
4951
})
5052
const data = response.data
5153
if (data.responseInfo.status === 'OK') {
52-
tasks.value = offset.value === 0 ? data.tasks : [...tasks.value, ...data.tasks]
53-
hasMore.value = data.tasks.length === limit.value
54-
offset.value += data.tasks.length
54+
const fetchedTasks = data.tasks || []
55+
tasks.value = offset.value === 0 ? fetchedTasks : [...tasks.value, ...fetchedTasks]
56+
hasMore.value = fetchedTasks.length === limit.value
57+
offset.value += fetchedTasks.length
58+
noTasks.value = offset.value === 0 && fetchedTasks.length === 0
5559
} else {
5660
throw new Error('Invalid response status')
5761
}
@@ -163,6 +167,13 @@ onMounted(loadTasks)
163167
margin-top: clamp(0.625rem, 1.25vw, 1.25rem);
164168
}
165169
170+
.no-tasks-message {
171+
text-align: center;
172+
font-size: clamp(1rem, 1.5vw, 1.2em);
173+
color: #6f6a6a;
174+
margin-top: clamp(0.625rem, 1.25vw, 1.25rem);
175+
}
176+
166177
.content-container {
167178
width: 100%;
168179
display: flex;

src/views/SolveSkips.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="solve-skips-page-wrapper">
33
<div v-if="loading" class="loading-message">Looking for tasks...</div>
4+
<div v-else-if="noTasks" class="no-tasks-message">No tasks available yet. Create a task and be the first to publish!</div>
45
<div v-else-if="error" class="error-message">{{ error }}</div>
56
<div v-else class="content-container">
67
<h2 class="section-header">Available Skips Tasks</h2>
@@ -36,6 +37,7 @@ const limit = ref(10)
3637
const hasMore = ref(true)
3738
const loadingMore = ref(false)
3839
const loadingRandom = ref(false)
40+
const noTasks = ref(false)
3941
4042
const loadTasks = async () => {
4143
loading.value = true
@@ -49,9 +51,11 @@ const loadTasks = async () => {
4951
})
5052
const data = response.data
5153
if (data.responseInfo.status === 'OK') {
52-
tasks.value = offset.value === 0 ? data.tasks : [...tasks.value, ...data.tasks]
53-
hasMore.value = data.tasks.length === limit.value
54-
offset.value += data.tasks.length
54+
const fetchedTasks = data.tasks || []
55+
tasks.value = offset.value === 0 ? fetchedTasks : [...tasks.value, ...fetchedTasks]
56+
hasMore.value = fetchedTasks.length === limit.value
57+
offset.value += fetchedTasks.length
58+
noTasks.value = offset.value === 0 && fetchedTasks.length === 0
5559
} else {
5660
throw new Error('Invalid response status')
5761
}
@@ -163,6 +167,13 @@ onMounted(loadTasks)
163167
margin-top: clamp(0.625rem, 1.25vw, 1.25rem);
164168
}
165169
170+
.no-tasks-message {
171+
text-align: center;
172+
font-size: clamp(1rem, 1.5vw, 1.2em);
173+
color: #6f6a6a;
174+
margin-top: clamp(0.625rem, 1.25vw, 1.25rem);
175+
}
176+
166177
.content-container {
167178
width: 100%;
168179
display: flex;

0 commit comments

Comments
 (0)