All files / src/app/pages/account/account-user-info account-user-info.component.ts

100% Statements 13/13
75% Branches 3/4
100% Functions 6/6
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 322x   2x   2x                 2x           4x     4x 4x 4x 4x 2x 1x        
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
 
import { AccountFacade } from 'ish-core/facades/account.facade';
import { Customer } from 'ish-core/models/customer/customer.model';
import { User } from 'ish-core/models/user/user.model';
 
@Component({
  selector: 'ish-account-user-info',
  templateUrl: './account-user-info.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccountUserInfoComponent implements OnInit {
  isBusinessUser$: Observable<boolean>;
  user$: Observable<User>;
  customer$: Observable<Customer>;
  roles$: Observable<string>;
 
  constructor(private accountFacade: AccountFacade) {}
 
  ngOnInit() {
    this.isBusinessUser$ = this.accountFacade.customer$.pipe(map(user => !!user?.isBusinessCustomer));
    this.user$ = this.accountFacade.user$;
    this.customer$ = this.accountFacade.customer$;
    this.roles$ = this.accountFacade.roles$.pipe(
      map(roles => roles.map(role => role.displayName)),
      map(a => a.join(', '))
    );
  }
}