Created a student performance page
This commit is contained in:
@@ -11,11 +11,11 @@ export const USER_TYPE_LABELS: {[key in Type]: string} = {
|
||||
};
|
||||
|
||||
export function isCorporateUser(user: User): user is CorporateUser {
|
||||
return (user as CorporateUser).corporateInformation !== undefined;
|
||||
return (user as CorporateUser)?.corporateInformation !== undefined;
|
||||
}
|
||||
|
||||
export function isAgentUser(user: User): user is AgentUser {
|
||||
return (user as AgentUser).agentInformation !== undefined;
|
||||
return (user as AgentUser)?.agentInformation !== undefined;
|
||||
}
|
||||
|
||||
export function getUserCompanyName(user: User, users: User[], groups: Group[]) {
|
||||
@@ -30,3 +30,15 @@ export function getUserCompanyName(user: User, users: User[], groups: Group[]) {
|
||||
const admin = belongingGroupsAdmins[0] as CorporateUser;
|
||||
return admin.corporateInformation?.companyInformation.name || admin.name;
|
||||
}
|
||||
|
||||
export function getCorporateUser(user: User, users: User[], groups: Group[]) {
|
||||
if (isCorporateUser(user)) return user;
|
||||
|
||||
const belongingGroups = groups.filter((x) => x.participants.includes(user.id));
|
||||
const belongingGroupsAdmins = belongingGroups.map((x) => users.find((u) => u.id === x.admin)).filter((x) => !!x && isCorporateUser(x));
|
||||
|
||||
if (belongingGroupsAdmins.length === 0) return undefined;
|
||||
|
||||
const admin = belongingGroupsAdmins[0] as CorporateUser;
|
||||
return admin;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user