diff --git a/src/app/profile/profile.component.html b/src/app/profile/profile.component.html index f374fb6b8b3c989cff57dd215ba8dd0bfa3d9175..00f5d7373312859181196b7fc2d039734e0ebb8d 100644 --- a/src/app/profile/profile.component.html +++ b/src/app/profile/profile.component.html @@ -36,7 +36,7 @@ ></app-svg-icon> <div class="information"> <div class="name">{{ userProfile.name }} {{ userProfile.surname }}</div> - <div class="job">{{ userProfile.job.name }}, {{ userProfile.employer.name }}</div> + <div *ngIf="utils.getJobEmployer(userProfile)" class="job">{{ utils.getJobEmployer(userProfile) }}</div> <div class="phone">{{ userProfile.phone | phone }}</div> <a class="email" href="mailto:{{ userProfile.email }}">{{ userProfile.email }}</a> <div class="description" *ngIf="userProfile.description">{{ userProfile.description }}</div> diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index 2a2810b384606d33dfcb531d353164ee438c53d9..c92d54a5d353adb5b21a77d1f48e873dadcf1508 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -5,6 +5,7 @@ import { User } from '../models/user.model'; import { StructureService } from '../services/structure.service'; import { ButtonType } from '../shared/components/button/buttonType.enum'; import { ProfileService } from './services/profile.service'; +import { Utils } from '../utils/utils'; @Component({ selector: 'app-profile', @@ -19,7 +20,8 @@ export class ProfileComponent implements OnInit { constructor( private profileService: ProfileService, private structureService: StructureService, - private router: Router + private router: Router, + public utils: Utils ) {} ngOnInit(): void { diff --git a/src/app/utils/utils.ts b/src/app/utils/utils.ts index a949f40fd15cdf46fe384a456588812f97ef008b..313183529ee6d45804cf7af1c3cfb6cb9cbe1e56 100644 --- a/src/app/utils/utils.ts +++ b/src/app/utils/utils.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { FormGroup } from '@angular/forms'; +import { User } from '../models/user.model'; @Injectable({ providedIn: 'root', @@ -25,4 +26,13 @@ export class Utils { } return phoneNumber; } + + public getJobEmployer(userProfile: User): string { + const jobName = userProfile.job?.name; + const employerName = userProfile.employer?.name; + if (!jobName && !employerName) return ''; + if (!jobName && employerName) return employerName; + if (jobName && !employerName) return jobName; + if (jobName && employerName) return `${jobName}, ${employerName}`; + } }