ENCOA-37: Added the ability for users to download a list of the shown users
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Type, User, CorporateUser, AgentUser} from "@/interfaces/user";
|
||||
import {Type, User, CorporateUser, AgentUser, Group} from "@/interfaces/user";
|
||||
|
||||
export const USER_TYPE_LABELS: {[key in Type]: string} = {
|
||||
student: "Student",
|
||||
@@ -16,3 +16,16 @@ export function isCorporateUser(user: User): user is CorporateUser {
|
||||
export function isAgentUser(user: User): user is AgentUser {
|
||||
return (user as AgentUser).agentInformation !== undefined;
|
||||
}
|
||||
|
||||
export function getUserCompanyName(user: User, users: User[], groups: Group[]) {
|
||||
if (isCorporateUser(user)) return user.corporateInformation?.companyInformation?.name || user.name;
|
||||
if (isAgentUser(user)) return user.agentInformation?.companyName || user.name;
|
||||
|
||||
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 "";
|
||||
|
||||
const admin = belongingGroupsAdmins[0] as CorporateUser;
|
||||
return admin.corporateInformation?.companyInformation.name || admin.name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user