All files / src/app/extensions/punchout/pages/account-punchout-create account-punchout-create-page.component.ts

80% Statements 8/10
75% Branches 3/4
66.66% Functions 2/3
80% Lines 8/10

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 32 331x   1x       1x               1x         1x     1x 1x 1x                
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { v4 as uuid } from 'uuid';
 
import { HttpError } from 'ish-core/models/http-error/http-error.model';
 
import { PunchoutFacade } from '../../facades/punchout.facade';
import { PunchoutType, PunchoutUser } from '../../models/punchout-user/punchout-user.model';
 
@Component({
  selector: 'ish-account-punchout-create-page',
  templateUrl: './account-punchout-create-page.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccountPunchoutCreatePageComponent implements OnInit {
  loading$: Observable<boolean>;
  error$: Observable<HttpError>;
  selectedType$: Observable<PunchoutType>;
 
  constructor(private punchoutFacade: PunchoutFacade) {}
 
  ngOnInit() {
    this.loading$ = this.punchoutFacade.punchoutLoading$;
    this.error$ = this.punchoutFacade.punchoutError$;
    this.selectedType$ = this.punchoutFacade.selectedPunchoutType$;
  }
 
  submitForm(user: PunchoutUser) {
    const email = user.login + uuid();
    this.punchoutFacade.addPunchoutUser({ ...user, email });
  }
}