feat: admin can get all courses within org
This commit is contained in:
@@ -23,8 +23,10 @@
|
||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||
import { calDateDiff } from '$lib/utils/functions/date';
|
||||
import { browser } from '$app/environment';
|
||||
import { fetchCourses } from '$lib/components/Courses/api.js';
|
||||
import { t } from '$lib/utils/functions/translations.js';
|
||||
import { fetchCourses } from '$lib/components/Courses/api';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { courses } from '$lib/components/Courses/store';
|
||||
import type { Course } from '$lib/utils/types';
|
||||
|
||||
export let data;
|
||||
const { slug } = data;
|
||||
@@ -86,7 +88,7 @@
|
||||
};
|
||||
|
||||
let editorInstance = false;
|
||||
let fetchedCourses = [];
|
||||
let fetchedCourses: Course[] = [];
|
||||
|
||||
function mapResToQuestion(data): Question {
|
||||
return {
|
||||
@@ -115,8 +117,13 @@
|
||||
}
|
||||
|
||||
async function getCourses(userId: string | null, orgId: string) {
|
||||
if ($courses.length) {
|
||||
fetchedCourses = [...$courses];
|
||||
return;
|
||||
}
|
||||
|
||||
const coursesResults = await fetchCourses(userId, orgId);
|
||||
fetchedCourses = coursesResults.allCourses;
|
||||
fetchedCourses = coursesResults?.allCourses || [];
|
||||
}
|
||||
|
||||
async function fetchCommunityQuestion(slug: string) {
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
import { profile } from '$lib/utils/store/user';
|
||||
import { fetchCourses } from '$lib/components/Courses/api';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { courses } from '$lib/components/Courses/store';
|
||||
import type { Course } from '$lib/utils/types';
|
||||
|
||||
let errors: {
|
||||
title?: string;
|
||||
@@ -24,11 +26,16 @@
|
||||
courseId: ''
|
||||
};
|
||||
|
||||
let fetchedCourses = [];
|
||||
let fetchedCourses: Course[] = [];
|
||||
|
||||
async function getCourses(userId: string | null, orgId: string) {
|
||||
if ($courses.length) {
|
||||
fetchedCourses = [...$courses];
|
||||
return;
|
||||
}
|
||||
|
||||
const coursesResults = await fetchCourses(userId, orgId);
|
||||
fetchedCourses = coursesResults.allCourses;
|
||||
fetchedCourses = coursesResults?.allCourses || [];
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
|
||||
Reference in New Issue
Block a user