feat: add 4 certificate templates (#295)
* add cloud translation api package * feat: Script that auto generates translations for other languages * add comments * fix: broken translation * improve translation * update locck file * clean up * all round trasnlations check * checkpoint * finish up * move to dev dependencies * fix vercel build error * translations fix * - add documentation - translation bug fix * quick adjust * PR Fixes * add new line * update docs * checkpoint * feat: redesign & addition of certificates * text color update * patterned width fix * "student-name" class remove * checkpoint * PR Fix * quick fix * PR Fixes * update certificate ready page for students * PR Fixes * quick cleanup * move fetchCourses into .ts file * feat: give students access to certificates only after completing course * checkpoint * height fix * Merge branch 'main' of https://github.com/rotimi-best/classroomio into classroomio-issue-272 * Fix; merge PR Fix * fix: width of plain & professional certs * PR Fix * feat: add translation * handle error when trying to download a certificate * add fetchExploreCourses * fix: requested reviews * review fixes checkpoint * replace the certificate background * height fix for patterned certififcates * fix more bugs * rename schema --------- Co-authored-by: Rotimi Best <best@classroomio.com>
This commit is contained in:
co-authored by
Rotimi Best
parent
f0907dde89
commit
72b58ed2c7
@@ -1,3 +1,4 @@
|
||||
import { get } from 'svelte/store';
|
||||
import { supabase } from '$lib/utils/functions/supabase';
|
||||
import { isUUID } from '$lib/utils/functions/isUUID';
|
||||
import { QUESTION_TYPE } from '$lib/components/Question/constants';
|
||||
@@ -11,7 +12,53 @@ import type {
|
||||
ExerciseTemplate
|
||||
} from '$lib/utils/types';
|
||||
import { STATUS } from '$lib/utils/constants/course';
|
||||
import type { PostgrestSingleResponse } from '@supabase/supabase-js';
|
||||
import type { PostgrestSingleResponse, PostgrestError } from '@supabase/supabase-js';
|
||||
import type { ProfileCourseProgress } from '$lib/utils/types';
|
||||
import { isOrgAdmin } from '$lib/utils/store/org';
|
||||
|
||||
export async function fetchCourses(profileId, orgId) {
|
||||
if (!orgId || !profileId) return;
|
||||
|
||||
const match = {};
|
||||
// Filter by profile_id if role isn't admin within organization
|
||||
if (!get(isOrgAdmin)) {
|
||||
match.member_profile_id = profileId;
|
||||
}
|
||||
|
||||
// Gets courses for a particular organisation where the current logged in user is a groupmember
|
||||
const { data: allCourses } = await supabase
|
||||
.rpc('get_courses', {
|
||||
org_id_arg: orgId,
|
||||
profile_id_arg: profileId
|
||||
})
|
||||
.match(match);
|
||||
|
||||
console.log(`allCourses`, allCourses);
|
||||
if (!Array.isArray(allCourses)) {
|
||||
return {
|
||||
allCourses: []
|
||||
};
|
||||
}
|
||||
|
||||
return { allCourses };
|
||||
}
|
||||
|
||||
export async function fetchProfileCourseProgress(
|
||||
courseId,
|
||||
profileId
|
||||
): Promise<{
|
||||
data: ProfileCourseProgress[] | null;
|
||||
error: PostgrestError | null;
|
||||
}> {
|
||||
const { data, error } = await supabase
|
||||
.rpc('get_course_progress', {
|
||||
course_id_arg: courseId,
|
||||
profile_id_arg: profileId
|
||||
})
|
||||
.returns<ProfileCourseProgress[]>();
|
||||
|
||||
return { data, error };
|
||||
}
|
||||
|
||||
const SLUG_QUERY = `
|
||||
id,
|
||||
@@ -95,6 +142,23 @@ export async function fetchCourse(courseId?: Course['id'], slug?: Course['slug']
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchExploreCourses(profileId, orgId) {
|
||||
if (!orgId || !profileId) return;
|
||||
|
||||
const { data: allCourses } = await supabase.rpc('get_explore_courses', {
|
||||
org_id_arg: orgId,
|
||||
profile_id_arg: profileId
|
||||
});
|
||||
|
||||
if (!Array.isArray(allCourses)) {
|
||||
return {
|
||||
allCourses: []
|
||||
};
|
||||
}
|
||||
|
||||
return { allCourses };
|
||||
}
|
||||
|
||||
export async function fetchGroup(groupId: Group['id']) {
|
||||
const { data, error } = await supabase
|
||||
.from('group')
|
||||
|
||||
Reference in New Issue
Block a user