ENCOA-272

This commit is contained in:
Tiago Ribeiro
2024-12-11 11:58:52 +00:00
parent 6a6c4661c4
commit d074ec390c
46 changed files with 1940 additions and 6423 deletions

View File

@@ -1,6 +1,6 @@
import {Type, User, CorporateUser, AgentUser, Group} from "@/interfaces/user";
import { Type, User, CorporateUser, AgentUser, Group } from "@/interfaces/user";
export const USER_TYPE_LABELS: {[key in Type]: string} = {
export const USER_TYPE_LABELS: { [key in Type]: string } = {
student: "Student",
teacher: "Teacher",
corporate: "Corporate",
@@ -19,8 +19,8 @@ export function isAgentUser(user: User): user is AgentUser {
}
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;
if (isCorporateUser(user)) return 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));
@@ -28,7 +28,7 @@ export function getUserCompanyName(user: User, users: User[], groups: Group[]) {
if (belongingGroupsAdmins.length === 0) return "";
const admin = belongingGroupsAdmins[0] as CorporateUser;
return admin.corporateInformation?.companyInformation.name || admin.name;
return admin.name;
}
export function getCorporateUser(user: User, users: User[], groups: Group[]) {