File

src/app/sending-money/paying-again/paying-again.component.ts

Implements

OnInit

Metadata

selector app-paying-again
styleUrls paying-again.component.css
templateUrl ./paying-again.component.html

Index

Properties
Methods
Outputs

Constructor

constructor(app: AppState, router: Router)
Parameters :
Name Type Optional
app AppState no
router Router no

Outputs

isSubmitPayment $event type: EventEmitter

Methods

ngOnInit
ngOnInit()
Returns : void
resetPayAgainForm
resetPayAgainForm()
Returns : void
submit
submit()
Returns : void
submitPayment
submitPayment()
Returns : void

Properties

Public app
app: AppState
Type : AppState
isValid
isValid:
Default value : false
memo
memo: string
Type : string
Default value : ''
memoinput
memoinput: ElementRef
Type : ElementRef
Decorators : ViewChild
payagainform
payagainform:
Decorators : ViewChild
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { debounceTime, filter, map } from 'rxjs/operators';
import { AppState } from '../../stores/app-state.store';

@Component({
  selector: 'app-paying-again',
  templateUrl: './paying-again.component.html',
  styleUrls: ['./paying-again.component.css']
})
export class PayingAgainComponent implements OnInit {
  @ViewChild('userFormPayAgain')
  payagainform;
  @ViewChild('memoInput')
  memoinput: ElementRef;
  @Output()
  isSubmitPayment = new EventEmitter();
  memo = '';
  isValid = false;

  constructor(public app: AppState, private router: Router) {}

  ngOnInit() {
    this.app.state$
      .pipe(
        debounceTime(500),
        filter(state => state !== null && state !== undefined),
        map(state => state.isValid)
      )
      .subscribe(isValid => {
        this.isValid = isValid;
      });
  }

  submit() {
    this.app.payment.memo = this.memo;
    if (!this.app.hasPassedMfa) {
      this.router.navigate(['/payment/create']);
    } else {
      if (this.isValid) {
        this.submitPayment();
      }
    }
  }

  submitPayment() {
    this.isSubmitPayment.emit();
  }

  resetPayAgainForm() {
    this.payagainform.reset();
  }
}
<form #userFormPayAgain="ngForm">
  <p class="paying-again">Send a message with your payment (Optional)</p>

  <input
    type="text"
    #memoInput
    (keydown.Enter)="submit()"
    [(ngModel)]="memo"
    id="memo"
    name="note"
    tabindex="3"
    placeholder="Dinner, Rent, Etc."
    pattern="[A-Za-z0-9,\s!.'-]+"
    autocomplete="off"
  />

  <span>
    <div [hidden]="userFormPayAgain.valid || userFormPayAgain.pristine" class="alert alert-danger text-align">
      Please only use A-Z, a-z, 0-9, periods, commas, dashes, spaces, apostrophes, and exclamation points
    </div>
  </span>

  <button
    [disabled]="!isValid || !userFormPayAgain.valid"
    form="mainForm"
    type="button"
    (click)="submit()"
    class="action-button"
    id="submitButton"
    tabindex="4"
  >
    <p class="button-inside" *ngIf="!app.hasPassedMfa">Continue To The Next Step</p>
    <p class="button-inside" *ngIf="app.hasPassedMfa">Send Money</p>
  </button>
</form>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""