mirror of
https://github.com/valitydev/dashboard.git
synced 2024-11-06 02:25:23 +00:00
MI-21: Fix withdrawal error message (#146)
This commit is contained in:
parent
c152e05222
commit
757bc46e38
8
package-lock.json
generated
8
package-lock.json
generated
@ -25,7 +25,7 @@
|
||||
"@sentry/angular-ivy": "^7.63.0",
|
||||
"@sentry/integrations": "^7.63.0",
|
||||
"@sentry/tracing": "^7.63.0",
|
||||
"@vality/ng-core": "^16.2.1-pr-33-c999544.0",
|
||||
"@vality/ng-core": "^16.2.1-pr-33-89c646b.0",
|
||||
"@vality/swag-anapi-v2": "2.0.0",
|
||||
"@vality/swag-api-keys-v2": "^0.1.2-870c41d.0",
|
||||
"@vality/swag-claim-management": "0.1.1-7a03f9b.0",
|
||||
@ -6409,9 +6409,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vality/ng-core": {
|
||||
"version": "16.2.1-pr-33-c999544.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-33-c999544.0.tgz",
|
||||
"integrity": "sha512-2CqoYXqFS5Dr0Dzl/+YU6z+bKI+yNJib5PfFO5OZeh4RnWd9Iktse4lSOCynbqFQ8qarWq/FkA2EYoluD4waFQ==",
|
||||
"version": "16.2.1-pr-33-89c646b.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-33-89c646b.0.tgz",
|
||||
"integrity": "sha512-8qDubL4XhAtP4GoPY/W5FSa6/4+rzqCCRq/91nWpYX3Vquta1SZi02bXv0S7oxJMNr+pNUUHw6qHkbDhFbKgBA==",
|
||||
"dependencies": {
|
||||
"@ng-matero/extensions": "^16.0.0",
|
||||
"@s-libs/js-core": "^16.0.0",
|
||||
|
@ -42,7 +42,7 @@
|
||||
"@sentry/angular-ivy": "^7.63.0",
|
||||
"@sentry/integrations": "^7.63.0",
|
||||
"@sentry/tracing": "^7.63.0",
|
||||
"@vality/ng-core": "^16.2.1-pr-33-c999544.0",
|
||||
"@vality/ng-core": "^16.2.1-pr-33-89c646b.0",
|
||||
"@vality/swag-anapi-v2": "2.0.0",
|
||||
"@vality/swag-api-keys-v2": "^0.1.2-870c41d.0",
|
||||
"@vality/swag-claim-management": "0.1.1-7a03f9b.0",
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { TranslocoService } from '@ngneat/transloco';
|
||||
import { AsyncTransform } from '@vality/ng-core';
|
||||
import { PaymentError } from '@vality/swag-payments';
|
||||
import lowerCase from 'lodash-es/lowerCase';
|
||||
import upperFirst from 'lodash-es/upperFirst';
|
||||
import { isObservable, Observable, of } from 'rxjs';
|
||||
|
||||
function renderSubErrorMessage(error?: string, sub?: string) {
|
||||
if (!error) return sub;
|
||||
@ -17,15 +19,18 @@ function getErrorLabel(error: PaymentError) {
|
||||
|
||||
@Pipe({
|
||||
name: 'withdrawalErrorMessage',
|
||||
pure: false,
|
||||
})
|
||||
export class WithdrawalErrorMessagePipe implements PipeTransform {
|
||||
constructor(private t: TranslocoService) {}
|
||||
export class WithdrawalErrorMessagePipe extends AsyncTransform<string> implements PipeTransform {
|
||||
constructor(private t: TranslocoService) {
|
||||
super();
|
||||
}
|
||||
|
||||
transform(error: PaymentError): string {
|
||||
protected getValue(error: PaymentError) {
|
||||
return this.formatErrors(error);
|
||||
}
|
||||
|
||||
private formatErrors(error: PaymentError): string {
|
||||
private formatErrors(error: PaymentError): Observable<string> {
|
||||
let curError: PaymentError = error;
|
||||
let translation = this.getErrorDict();
|
||||
|
||||
@ -34,15 +39,15 @@ export class WithdrawalErrorMessagePipe implements PipeTransform {
|
||||
curError = curError.subError;
|
||||
}
|
||||
|
||||
if (typeof translation === 'string') return translation;
|
||||
return getErrorLabel(error);
|
||||
if (isObservable(translation)) return translation as Observable<string>;
|
||||
return of(getErrorLabel(error));
|
||||
}
|
||||
|
||||
private getErrorDict() {
|
||||
return {
|
||||
failed: this.t.translate('withdrawalErrorMessage.failed', null, 'wallet-section'),
|
||||
failed: this.t.selectTranslate('withdrawalErrorMessage.failed', null, 'wallet-section'),
|
||||
authorization_failed: {
|
||||
unknown: this.t.translate(
|
||||
unknown: this.t.selectTranslate(
|
||||
'withdrawalErrorMessage.authorization_failed.unknown',
|
||||
null,
|
||||
'wallet-section',
|
||||
|
Loading…
Reference in New Issue
Block a user