fix: org improvements (#385)

* fix: verify newly added admins

* allow adding of admins for paid customers

* feat: permit admins to see all courses
This commit is contained in:
Rotimi Best
2024-07-08 06:45:26 +01:00
committed by GitHub
parent ae2fe71353
commit b60b45ed26
3 changed files with 11 additions and 9 deletions
@@ -14,6 +14,7 @@
import Modal from '$lib/components/Modal/index.svelte';
import { t } from '$lib/utils/functions/translations';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import { isOrgAdmin } from '$lib/utils/store/org';
export let courseId = '';
export let path = '';
@@ -56,7 +57,7 @@
$globalStore.isStudent = user.role_id === 3;
filterPollsByStatus($globalStore.isStudent);
} else if ($profile.id && $group.people.length) {
} else if (!$isOrgAdmin && $profile.id && $group.people.length) {
// Current User doesn't have permission to view
isPermitted = false;
}
@@ -27,7 +27,7 @@
let role = ROLE.TUTOR;
let isFetching = false;
let isLoading = false;
let isRemoving = false;
let isRemoving: number | null = null;
async function onSendInvite() {
const { hasError, error: _error, emails } = validateEmailInString(emailsStr);
@@ -106,8 +106,8 @@
async function onRemove(id: number) {
console.log('onRemove called');
isRemoving = true;
const { data, error } = await supabase.from('organizationmember').delete().match({ id });
isRemoving = id;
const { error } = await supabase.from('organizationmember').delete().match({ id });
if (error) {
console.error('onRemove:', error);
@@ -116,7 +116,7 @@
orgTeam.update((team) => [...team.filter((member) => member.id !== id)]);
}
isRemoving = false;
isRemoving = null;
}
const fetchTeam = async (id: string) => {
@@ -160,7 +160,7 @@
class="mb-5 w-40"
disabled={$isFreePlan}
>
<!-- <SelectItem value={ROLE.ADMIN} text={ROLE_LABEL[ROLE.ADMIN]} /> -->
<SelectItem value={ROLE.ADMIN} text={ROLE_LABEL[ROLE.ADMIN]} />
<SelectItem value={ROLE.TUTOR} text={$t(ROLE_LABEL[ROLE.TUTOR])} />
</Select>
@@ -204,8 +204,8 @@
label={$t('course.navItem.people.teams.remove')}
variant={VARIANTS.TEXT_DANGER}
onClick={() => onRemove(teamMember.id)}
isLoading={isRemoving}
isDisabled={isRemoving}
isLoading={isRemoving === teamMember.id}
isDisabled={isRemoving === teamMember.id}
/>
{/if}
</div>
@@ -161,7 +161,8 @@
.insert({
organization_id: orgData.id,
profile_id: $profile.id,
role_id: 1
role_id: 1,
verified: true
})
.select();
console.log('Create organisation member', data);