All files / src/app/extensions/contact-us/pages/contact contact-page.component.ts

81.81% Statements 9/11
75% Branches 6/8
75% Functions 3/4
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 33 34 35 36 37 38 39 40 41 42 431x 1x         1x             1x                     1x     1x 1x                     1x      
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
 
import { Contact } from 'ish-core/models/contact/contact.model';
 
import { ContactUsFacade } from '../../facades/contact-us.facade';
 
@Component({
  selector: 'ish-contact-page',
  templateUrl: './contact-page.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ContactPageComponent implements OnInit, OnDestroy {
  /**
   * Indicator for any loading state.
   */
  loading$: Observable<boolean>;
  /**
   * In 'undefined' state the contact form is displayed.
   * Once 'success' is set to true or false the confirmation page is shown.
   */
  success$: Observable<boolean>;
 
  constructor(private contactUsFacade: ContactUsFacade, private router: Router) {}
 
  ngOnInit() {
    this.loading$ = this.contactUsFacade.contactLoading$;
    this.success$ = this.contactUsFacade.contactSuccess$;
  }
 
  /** dispatch contact request */
  createRequest(contact: Contact) {
    this.contactUsFacade.createContact(contact);
    this.router.navigate([], { queryParams: { submitted: true } });
  }
 
  ngOnDestroy() {
    // reset contact page if the user routes to 'contact' again
    this.contactUsFacade.resetContactState();
  }
}