diff --git a/portal-frontend/src/app/features/home/home.component.html b/portal-frontend/src/app/features/home/home.component.html index 9830090366..b7829d1d5c 100644 --- a/portal-frontend/src/app/features/home/home.component.html +++ b/portal-frontend/src/app/features/home/home.component.html @@ -1,5 +1,8 @@
+
+
{{ profile.government || profile.businessName }}
+

Portal Inbox

diff --git a/portal-frontend/src/app/features/home/home.component.spec.ts b/portal-frontend/src/app/features/home/home.component.spec.ts index f559c86a8c..274b36e9a1 100644 --- a/portal-frontend/src/app/features/home/home.component.spec.ts +++ b/portal-frontend/src/app/features/home/home.component.spec.ts @@ -2,7 +2,10 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MatDialogModule } from '@angular/material/dialog'; import { RouterTestingModule } from '@angular/router/testing'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { BehaviorSubject } from 'rxjs'; import { ApplicationSubmissionService } from '../../services/application-submission/application-submission.service'; +import { UserDto } from '../../services/authentication/authentication.dto'; import { AuthenticationService } from '../../services/authentication/authentication.service'; import { HomeComponent } from './home.component'; @@ -10,15 +13,19 @@ import { HomeComponent } from './home.component'; describe('HomeComponent', () => { let component: HomeComponent; let fixture: ComponentFixture; + let mockAuthService: DeepMocked; beforeEach(async () => { + mockAuthService = createMock(); + mockAuthService.$currentProfile = new BehaviorSubject(undefined); + await TestBed.configureTestingModule({ imports: [RouterTestingModule, MatDialogModule], declarations: [HomeComponent], providers: [ { provide: AuthenticationService, - useValue: {}, + useValue: mockAuthService, }, { provide: ApplicationSubmissionService, diff --git a/portal-frontend/src/app/features/home/home.component.ts b/portal-frontend/src/app/features/home/home.component.ts index e9b2412b41..a95100b191 100644 --- a/portal-frontend/src/app/features/home/home.component.ts +++ b/portal-frontend/src/app/features/home/home.component.ts @@ -1,7 +1,8 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; +import { Subject, takeUntil } from 'rxjs'; +import { UserDto } from '../../services/authentication/authentication.dto'; import { AuthenticationService } from '../../services/authentication/authentication.service'; -import { OverlaySpinnerService } from '../../shared/overlay-spinner/overlay-spinner.service'; import { CreateSubmissionDialogComponent } from '../create-submission-dialog/create-submission-dialog.component'; @Component({ @@ -9,21 +10,22 @@ import { CreateSubmissionDialogComponent } from '../create-submission-dialog/cre templateUrl: './home.component.html', styleUrls: ['./home.component.scss'], }) -export class HomeComponent implements OnInit { - public name = ''; +export class HomeComponent implements OnInit, OnDestroy { + $destroy = new Subject(); public isLearnMoreOpen = false; + profile: UserDto | undefined; - constructor( - private authenticationService: AuthenticationService, - private dialog: MatDialog, - private spinnerService: OverlaySpinnerService - ) {} + constructor(private authenticationService: AuthenticationService, private dialog: MatDialog) {} ngOnInit(): void { - const user = this.authenticationService.currentUser; - if (user) { - this.name = user.name; - } + this.authenticationService.$currentProfile.pipe(takeUntil(this.$destroy)).subscribe((profile) => { + this.profile = profile; + }); + } + + ngOnDestroy(): void { + this.$destroy.next(); + this.$destroy.complete(); } async onCreateApplication() { diff --git a/portal-frontend/src/app/shared/header/header.component.html b/portal-frontend/src/app/shared/header/header.component.html index e6a1a81016..ba6d59f015 100644 --- a/portal-frontend/src/app/shared/header/header.component.html +++ b/portal-frontend/src/app/shared/header/header.component.html @@ -36,7 +36,7 @@
User ID: {{ user?.bceidUserName }}
-
Business: {{ user?.businessName }}
+
Business: {{ user?.government || user?.businessName }}
Type: {{ user?.businessName ? 'BCeID Business' : 'BCeID Basic' }}