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
@@ -3,23 +3,31 @@
|
||||
import { group } from '../Course/store';
|
||||
import type { GroupPerson } from '$lib/utils/types';
|
||||
import { isOrgAdmin } from '$lib/utils/store/org';
|
||||
import { ROLE } from '$lib/utils/constants/roles';
|
||||
|
||||
export let allowedRoles: number[] = [];
|
||||
export let onDenied = () => {};
|
||||
export let onlyStudent = false;
|
||||
|
||||
let userRole: number = 0;
|
||||
|
||||
function isAllowed(userRole) {
|
||||
return allowedRoles.includes(userRole);
|
||||
}
|
||||
|
||||
$: {
|
||||
const user: GroupPerson = $group.people.find((person) => person.profile_id === $profile.id)!;
|
||||
|
||||
userRole = user ? user.role_id : userRole;
|
||||
|
||||
if (!$isOrgAdmin && $group.people.length && !allowedRoles.includes(userRole)) {
|
||||
if (!$isOrgAdmin && $group.people.length && !isAllowed(userRole)) {
|
||||
onDenied();
|
||||
}
|
||||
}
|
||||
|
||||
$: show = onlyStudent ? isAllowed(ROLE.STUDENT) : isAllowed(userRole) || $isOrgAdmin;
|
||||
</script>
|
||||
|
||||
{#if allowedRoles.includes(userRole) || $isOrgAdmin}
|
||||
{#if show}
|
||||
<slot />
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user