feat: admin can get all courses within org

This commit is contained in:
Rotimi Best
2024-05-22 05:49:10 +01:00
parent 6690b6bf34
commit 0536463ec9
15 changed files with 68 additions and 28 deletions
@@ -13,6 +13,7 @@
import { profile } from '$lib/utils/store/user';
import { Search, Dropdown } from 'carbon-components-svelte';
import { t } from '$lib/utils/functions/translations';
import { courses } from '$lib/components/Courses/store';
export let isLMS = false;
@@ -26,8 +27,12 @@
if (!orgId || !profileId) return;
isLoading = true;
const courseResult = (await fetchCourses(profileId, orgId)) || { allCourses: [] };
allCourses = courseResult.allCourses;
if ($courses.length) {
allCourses = [...$courses];
} else {
const courseResult = (await fetchCourses(profileId, orgId)) || { allCourses: [] };
allCourses = courseResult.allCourses;
}
const courseIds = allCourses.map((course) => course.id);
const courseIdsFilter = `(${courseIds.join(',')})`;