src/app/sending-money/paying-again/paying-again.component.ts
selector | app-paying-again |
styleUrls | paying-again.component.css |
templateUrl | ./paying-again.component.html |
Properties |
|
Methods |
Outputs |
constructor(app: AppState, router: Router)
|
isSubmitPayment
|
$event type: EventEmitter
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
resetPayAgainForm |
resetPayAgainForm()
|
Returns :
void
|
submit |
submit()
|
Returns :
void
|
submitPayment |
submitPayment()
|
Returns :
void
|
Public app |
app:
|
Type : AppState
|
isValid |
isValid:
|
Default value : false
|
memo |
memo:
|
Type : string
|
Default value : ''
|
memoinput |
memoinput:
|
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>