-
Notifications
You must be signed in to change notification settings - Fork 449
/
payments.ts
51 lines (43 loc) · 1.31 KB
/
payments.ts
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
import { Component, Input, OnInit, ViewChild, ElementRef } from '@angular/core';
import Warehouse from '@modules/server.common/entities/Warehouse';
import PaymentGateways, {
paymentGatewaysToString,
paymentGatewaysLogo
} from '@modules/server.common/enums/PaymentGateways';
@Component({
selector: 'merchant-payments-settings',
templateUrl: 'payments.html'
})
export class SettingsPaymentsComponent implements OnInit {
@Input()
currWarehouse: Warehouse;
showPaymentsGateways: boolean;
hasChanged: boolean;
myPaymentsGateways = [];
paymentsGateways = [];
selectedMyPaymentsGateways: PaymentGateways[];
selectedPaymentsGateways: PaymentGateways[];
ngOnInit(): void {
const merchantPaymentsGateways = this.currWarehouse.paymentGateways.map(
(mpg) => mpg.paymentGateway
);
const allPaymentGateways = Object.values(PaymentGateways).filter(
(r) => !isNaN(r)
);
if (merchantPaymentsGateways) {
this.myPaymentsGateways = allPaymentGateways.filter((pg) =>
merchantPaymentsGateways.includes(pg)
);
}
this.paymentsGateways = allPaymentGateways.filter(
(pg) => !this.myPaymentsGateways.includes(pg)
);
this.showPaymentsGateways = true;
}
getPaymentName(p: PaymentGateways) {
return paymentGatewaysToString(p);
}
getPaymentLogo(p: PaymentGateways) {
return paymentGatewaysLogo(p);
}
}