CLASSROOMIO-T-5: Educators Settings CRUD

Co-authored-by: Rotimi Best <[email protected]>

Merge-request: CLASSROOMIO-MR-7
Merged-by: Digdippa Team <[email protected]>
This commit is contained in:
Rotimi Best
2023-05-02 23:55:26 +00:00
committed by Space Cloud
co-authored by Rotimi Best
parent 01a1f0f907
commit 5f14b36ef8
27 changed files with 832 additions and 89 deletions
+46 -2
View File
@@ -1,5 +1,47 @@
import { supabase } from '../../functions/supabase';
import { orgs, currentOrg, orgAudience } from '../../store/org';
import { orgs, currentOrg, orgAudience, orgTeam } from '../../store/org';
import { ROLE, ROLE_LABEL } from '../../constants/roles';
export async function getOrgTeam(orgId) {
const { data, error } = await supabase
.from('organizationmember')
.select(
`
id,
email,
verified,
role_id,
profile(
id,
fullname,
email
)
`
)
.eq('organization_id', orgId)
.order('id', { ascending: false });
const team = [];
if (data?.length) {
data.forEach((teamMember) => {
team.push({
id: teamMember.id,
email: teamMember?.profile?.email || teamMember?.email,
verified: teamMember?.verified,
profileId: teamMember?.profile?.id,
role: ROLE_LABEL[teamMember?.role_id] || '',
isAdmin: teamMember?.role_id === ROLE.ADMIN,
});
});
orgTeam.set(team);
}
return {
team,
error,
};
}
export async function getOrganizations(userId) {
const { data, error } = await supabase
@@ -11,7 +53,8 @@ export async function getOrganizations(userId) {
organization (
id,
name,
siteName
siteName,
avatar_url
)
`
)
@@ -26,6 +69,7 @@ export async function getOrganizations(userId) {
shortName:
orgMember?.organization?.name?.substring(0, 2)?.toUpperCase() || '',
siteName: orgMember?.organization?.siteName,
avatar_url: orgMember?.organization?.avatar_url,
});
});