chore: proper certificate clean up + darkmode nav cleanup

This commit is contained in:
Rotimi Best
2024-11-21 15:25:42 +01:00
parent 660fc66bbb
commit 98c3060732
2 changed files with 9 additions and 4 deletions
@@ -3,13 +3,14 @@
import { group } from '../Course/store'; import { group } from '../Course/store';
import type { GroupPerson } from '$lib/utils/types'; import type { GroupPerson } from '$lib/utils/types';
import { isOrgAdmin } from '$lib/utils/store/org'; 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 = () => {}; export let onDenied = () => {};
// Since orgAdmin can see all, we need a way to show the content only to students
export let onlyStudent = false; export let onlyStudent = false;
let userRole: number = 0; let userRole: number = 0;
let show = false;
function isAllowed(userRole) { function isAllowed(userRole) {
return allowedRoles.includes(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;
}
</script> </script>
{#if show} {#if show}
@@ -36,7 +36,7 @@
<RoleBasedSecurity allowedRoles={[1, 2]}> <RoleBasedSecurity allowedRoles={[1, 2]}>
<Design /> <Design />
</RoleBasedSecurity> </RoleBasedSecurity>
<RoleBasedSecurity onlyStudent> <RoleBasedSecurity onlyStudent allowedRoles={[3]}>
<StudentCertificate /> <StudentCertificate />
</RoleBasedSecurity> </RoleBasedSecurity>