diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index b385727c58..bb785d0e04 100644 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -1,11 +1,17 @@ - + + +
-

{{displayName}} ({{visits | number}})

+ +

{{displayName}} ({{visits | number}})

+

- - , - + + + , + +

diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 7f19748be9..038786066b 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -31,6 +31,7 @@ export class DashboardComponent implements OnInit, OnDestroy { badgesCourses: { [key: string]: any[] } = {}; badgeGroups = [ ...foundations, 'none' ]; badgeIcons = foundationIcons; + user: any; dateNow: any; visits = 0; @@ -76,7 +77,14 @@ export class DashboardComponent implements OnInit, OnDestroy { ngOnInit() { const user = this.userService.get(); - this.displayName = user.firstName !== undefined ? user.firstName + ' ' + user.lastName : user.name; + + if (user) { + this.user = user; + this.displayName = user.firstName ? `${user.firstName} ${user.lastName}` : user.name; + } else { + console.warn('User data is missing or not initialized properly.'); + } + this.planetName = this.stateService.configuration.name; this.getSurveys(); this.getExams(); @@ -84,6 +92,7 @@ export class DashboardComponent implements OnInit, OnDestroy { this.couchService.findAll('login_activities', findDocuments({ 'user': this.userService.get().name }, [ 'user' ], [], 1000)) .pipe( catchError(() => { + console.warn('Error fetching login activities'); return of([]); }) ).subscribe((res: any) => {