From 22b1f22df427b020d71fc3cfa8b5fe4f22334c7c Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 31 Oct 2024 11:16:39 +0530 Subject: [PATCH] fix: empty state conditions --- frontend/src/pages/BatchForm.vue | 6 ++++++ frontend/src/pages/Batches.vue | 19 ++++++++++--------- frontend/src/pages/Courses.vue | 21 ++++++++++++--------- lms/lms/utils.py | 2 +- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/frontend/src/pages/BatchForm.vue b/frontend/src/pages/BatchForm.vue index b6da6785..865ae7f2 100644 --- a/frontend/src/pages/BatchForm.vue +++ b/frontend/src/pages/BatchForm.vue @@ -79,6 +79,11 @@ +
@@ -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, () => { diff --git a/frontend/src/pages/Courses.vue b/frontend/src/pages/Courses.vue index 587ac2f7..2b36f449 100644 --- a/frontend/src/pages/Courses.vue +++ b/frontend/src/pages/Courses.vue @@ -109,7 +109,7 @@
@@ -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, () => { diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 95860dba..a9e0260e 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -1101,7 +1101,7 @@ def get_categorized_courses(courses): ): new.append(course) - if course.membership and course.published: + if course.membership: enrolled.append(course) elif course.is_instructor: created.append(course)