All files / src/app/pages/forgot-password/request-reminder-form request-reminder-form.component.ts

64.28% Statements 9/14
66.66% Branches 2/3
75% Functions 3/4
64.28% Lines 9/14

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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 662x 2x       2x                             2x       4x   4x   4x       4x                                       4x                          
import { ChangeDetectionStrategy, Component, EventEmitter, OnInit, Output } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { FormlyFieldConfig } from '@ngx-formly/core';
 
import { PasswordReminder } from 'ish-core/models/password-reminder/password-reminder.model';
import { markAsDirtyRecursive } from 'ish-shared/forms/utils/form-utils';
 
/**
 * The Request Reminder Form Component displays a Forgot Password Request Reminder form and triggers the submit.
 *
 * @example
 * <ish-request-reminder-form
 *               (submitPasswordReminder)="requestPasswordReminder($event)"
 * ></ish-request-reminder-form>
 */
@Component({
  selector: 'ish-request-reminder-form',
  templateUrl: './request-reminder-form.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RequestReminderFormComponent implements OnInit {
  /**
   * Submit the form data to trigger the request for a password reminder.
   */
  @Output() submitPasswordReminder = new EventEmitter<PasswordReminder>();
 
  private submitted = false;
 
  requestReminderForm = new UntypedFormGroup({});
  fields: FormlyFieldConfig[];
 
  ngOnInit() {
    this.fields = [
      {
        key: 'email',
        type: 'ish-email-field',
        props: {
          label: 'account.forgotdata.email.label',
          hideRequiredMarker: true,
          required: true,
        },
      },
      {
        type: 'ish-captcha-field',
        props: {
          topic: 'forgotPassword',
        },
      },
    ];
  }
 
  get buttonDisabled() {
    return this.requestReminderForm.invalid && this.submitted;
  }
 
  submitForm() {
    Iif (this.requestReminderForm.invalid) {
      this.submitted = true;
      markAsDirtyRecursive(this.requestReminderForm);
      return;
    }
 
    this.submitPasswordReminder.emit(this.requestReminderForm.value);
  }
}