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)
3637const hasMore = ref (true )
3738const loadingMore = ref (false )
3839const loadingRandom = ref (false )
40+ const noTasks = ref (false )
3941
4042const 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