From 98c3060732047807d564fa471ba1a2be9ad70ed7 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Thu, 21 Nov 2024 15:25:42 +0100 Subject: [PATCH] chore: proper certificate clean up + darkmode nav cleanup --- .../src/lib/components/RoleBasedSecurity/index.svelte | 11 ++++++++--- .../src/routes/courses/[id]/certificates/+page.svelte | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/src/lib/components/RoleBasedSecurity/index.svelte b/apps/dashboard/src/lib/components/RoleBasedSecurity/index.svelte index b3ced824..e6b7779b 100644 --- a/apps/dashboard/src/lib/components/RoleBasedSecurity/index.svelte +++ b/apps/dashboard/src/lib/components/RoleBasedSecurity/index.svelte @@ -3,13 +3,14 @@ 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[] = [1, 2, 3]; + export let allowedRoles: number[] = []; export let onDenied = () => {}; + // Since orgAdmin can see all, we need a way to show the content only to students export let onlyStudent = false; let userRole: number = 0; + let show = false; function isAllowed(userRole) { return allowedRoles.includes(userRole); @@ -25,7 +26,11 @@ } } - $: show = onlyStudent ? isAllowed(ROLE.STUDENT) : isAllowed(userRole) || $isOrgAdmin; + $: if (onlyStudent) { + show = isAllowed(userRole); + } else { + show = isAllowed(userRole) || $isOrgAdmin; + } {#if show} diff --git a/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte b/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte index c0b909d8..0303c9e0 100644 --- a/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte +++ b/apps/dashboard/src/routes/courses/[id]/certificates/+page.svelte @@ -36,7 +36,7 @@ - +