fix: empty state conditions
This commit is contained in:
@@ -79,6 +79,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<MultiSelect
|
||||
v-model="instructors"
|
||||
doctype="User"
|
||||
:label="__('Instructors')"
|
||||
/>
|
||||
<div class="mb-4">
|
||||
<FormControl
|
||||
v-model="batch.description"
|
||||
@@ -237,6 +242,7 @@ import { useRouter } from 'vue-router'
|
||||
import { showToast } from '../utils'
|
||||
import { Image } from 'lucide-vue-next'
|
||||
import { capture } from '@/telemetry'
|
||||
import MultiSelect from '@/components/Controls/MultiSelect.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const user = inject('$user')
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
</Tabs>
|
||||
<div
|
||||
v-else-if="
|
||||
batches.fetched &&
|
||||
!batches.loading &&
|
||||
!hasBatches &&
|
||||
(user.data?.is_instructor || user.data?.is_moderator)
|
||||
"
|
||||
@@ -117,7 +117,7 @@
|
||||
</router-link>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="batches.fetched && !hasBatches"
|
||||
v-else-if="!batches.loading && !hasBatches"
|
||||
class="text-center p-5 text-gray-600 mt-52 w-3/4 md:w-1/2 mx-auto space-y-2"
|
||||
>
|
||||
<BookOpen class="size-10 mx-auto stroke-1 text-gray-500" />
|
||||
@@ -165,13 +165,6 @@ const batches = createResource({
|
||||
url: 'lms.lms.utils.get_batches',
|
||||
cache: ['batches', user.data?.email],
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
Object.keys(data).forEach((section) => {
|
||||
if (data[section].length) {
|
||||
hasBatches.value = true
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const categories = createResource({
|
||||
@@ -231,6 +224,14 @@ const addToTabs = (label) => {
|
||||
})
|
||||
}
|
||||
|
||||
watch(batches, () => {
|
||||
Object.keys(batches.data).forEach((key) => {
|
||||
if (batches.data[key].length) {
|
||||
hasBatches.value = true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
watch(
|
||||
() => currentCategory.value,
|
||||
() => {
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
</Tabs>
|
||||
<div
|
||||
v-else-if="
|
||||
courses.fetched &&
|
||||
!courses.loading &&
|
||||
(user.data?.is_moderator || user.data?.is_instructor)
|
||||
"
|
||||
class="grid grid-cols-3 p-5"
|
||||
@@ -138,7 +138,7 @@
|
||||
</router-link>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="courses.fetched && !hasCourses"
|
||||
v-else-if="!courses.loading && !hasCourses"
|
||||
class="text-center p-5 text-gray-600 mt-52 w-3/4 md:w-1/2 mx-auto space-y-2"
|
||||
>
|
||||
<BookOpen class="size-10 mx-auto stroke-1 text-gray-500" />
|
||||
@@ -187,13 +187,6 @@ const courses = createResource({
|
||||
url: 'lms.lms.utils.get_courses',
|
||||
cache: ['courses', user.data?.email],
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
Object.keys(data).forEach((section) => {
|
||||
if (data[section].length) {
|
||||
hasCourses.value = true
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const tabIndex = ref(0)
|
||||
@@ -271,6 +264,16 @@ const categories = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
watch(courses, () => {
|
||||
if (courses.data) {
|
||||
Object.keys(courses.data).forEach((section) => {
|
||||
if (courses.data[section].length) {
|
||||
hasCourses.value = true
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => currentCategory.value,
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user