pago-con-tarjeta.component.ts
1.41 KB
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
import { Component, OnInit } from '@angular/core';
import { BsModalRef } from 'ngx-bootstrap';
import { TarjetasService } from 'src/app/services/tarjetas.service';
import { Tarjeta } from 'src/app/wrappers/tarjeta';
import { FormGroup, FormControl, Validators } from '@angular/forms';
@Component({
selector: 'app-pago-con-tarjeta',
templateUrl: './pago-con-tarjeta.component.html',
styleUrls: ['./pago-con-tarjeta.component.scss'],
})
export class PagoConTarjetaComponent implements OnInit {
private showForm = false;
private importeTotal: number;
private tarjetas: Tarjeta[] = [];
private tarjetaSeleccionada: Tarjeta;
private form: FormGroup;
constructor(
private modalRef: BsModalRef,
private tarjetasService: TarjetasService,
) { }
ngOnInit() {
this.tarjetasService.getTarjetas()
.subscribe((res: Tarjeta[]) => {
this.tarjetas = res;
}, err => console.error(err));
this.setForm();
}
setForm() {
this.form = new FormGroup({
terminal: new FormControl('', [Validators.required, Validators.pattern("^[0-9]*$")]),
numeroCupon: new FormControl('', [Validators.required, Validators.pattern("^[0-9]*$")]),
cuotas: new FormControl('', [Validators.required, Validators.pattern("^[0-9]*$")]),
})
}
seleccionarTarjeta(tarjeta: Tarjeta) {
this.tarjetaSeleccionada = tarjeta;
this.showForm = true;
}
close() {
this.modalRef.hide()
}
}