diff --git a/apps/web/src/app/billing/shared/payment-method.component.html b/apps/web/src/app/billing/shared/payment-method.component.html index 2ac9233b5b..495785af45 100644 --- a/apps/web/src/app/billing/shared/payment-method.component.html +++ b/apps/web/src/app/billing/shared/payment-method.component.html @@ -3,7 +3,7 @@ type="button" bitButton buttonType="secondary" - (click)="load()" + [bitAction]="load" class="tw-ml-auto" *ngIf="firstLoaded" [disabled]="loading" @@ -14,115 +14,93 @@ -
- -

{{ "paymentMethod" | i18n }}

-
+ +

{{ "paymentMethod" | i18n }}

- {{ "loading" | i18n }} + {{ "loading" | i18n }} -

{{ (isCreditBalance ? "accountCredit" : "accountBalance") | i18n }}

-

- {{ creditOrBalance | currency: "$" }} -

-

{{ "creditAppliedDesc" | i18n }}

- -

{{ "paymentMethod" | i18n }}

-

{{ "noPaymentMethod" | i18n }}

- - -

{{ "verifyBankAccountDesc" | i18n }} {{ "verifyBankAccountFailureWarning" | i18n }}

-
+

+ {{ (isCreditBalance ? "accountCredit" : "accountBalance") | i18n }} +

+

{{ creditOrBalance | currency: "$" }}

+

{{ "creditAppliedDesc" | i18n }}

+ + + +

{{ "paymentMethod" | i18n }}

+

{{ "noPaymentMethod" | i18n }}

+ + - - {{ "amountX" | i18n: "1" }} - - $0. - - - {{ "amountX" | i18n: "2" }} - - $0. - - - -
-

- - {{ paymentSource.description }} + + {{ "amountX" | i18n: "1" }} + + $0. + + + {{ "amountX" | i18n: "2" }} + + $0. + + + + +

+ + {{ paymentSource.description }} +

+
+ +

+ {{ "paymentChargedWithUnpaidSubscription" | i18n }}

-
- -

{{ "paymentChargedWithUnpaidSubscription" | i18n }}

- -

{{ "taxInformation" | i18n }}

-

{{ "taxInformationDesc" | i18n }}

+ + +

{{ "taxInformation" | i18n }}

+

{{ "taxInformationDesc" | i18n }}

- {{ "loading" | i18n }} + {{ "loading" | i18n }}
-
+ -
-
+
diff --git a/apps/web/src/app/billing/shared/payment-method.component.ts b/apps/web/src/app/billing/shared/payment-method.component.ts index 967bff6d1a..eacc0b4739 100644 --- a/apps/web/src/app/billing/shared/payment-method.component.ts +++ b/apps/web/src/app/billing/shared/payment-method.component.ts @@ -38,9 +38,6 @@ export class PaymentMethodComponent implements OnInit { organizationId: string; isUnpaid = false; - verifyBankPromise: Promise; - taxFormPromise: Promise; - verifyBankForm = this.formBuilder.group({ amount1: new FormControl(null, [ Validators.required, @@ -54,6 +51,8 @@ export class PaymentMethodComponent implements OnInit { ]), }); + taxForm = this.formBuilder.group({}); + constructor( protected apiService: ApiService, protected organizationApiService: OrganizationApiServiceAbstraction, @@ -83,7 +82,7 @@ export class PaymentMethodComponent implements OnInit { }); } - async load() { + load = async () => { if (this.loading) { return; } @@ -109,7 +108,7 @@ export class PaymentMethodComponent implements OnInit { this.isUnpaid = this.subscription?.status === "unpaid" ?? false; this.loading = false; - } + }; addCredit = async () => { const dialogRef = openAddCreditDialog(this.dialogService, { @@ -136,35 +135,23 @@ export class PaymentMethodComponent implements OnInit { } }; - async verifyBank() { + verifyBank = async () => { if (this.loading || !this.forOrganization) { return; } - try { - const request = new VerifyBankRequest(); - request.amount1 = this.verifyBankForm.value.amount1; - request.amount2 = this.verifyBankForm.value.amount2; - this.verifyBankPromise = this.organizationApiService.verifyBank(this.organizationId, request); - await this.verifyBankPromise; - this.platformUtilsService.showToast( - "success", - null, - this.i18nService.t("verifiedBankAccount"), - ); - // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.load(); - } catch (e) { - this.logService.error(e); - } - } + const request = new VerifyBankRequest(); + request.amount1 = this.verifyBankForm.value.amount1; + request.amount2 = this.verifyBankForm.value.amount2; + await this.organizationApiService.verifyBank(this.organizationId, request); + this.platformUtilsService.showToast("success", null, this.i18nService.t("verifiedBankAccount")); + await this.load(); + }; - async submitTaxInfo() { - this.taxFormPromise = this.taxInfo.submitTaxInfo(); - await this.taxFormPromise; + submitTaxInfo = async () => { + await this.taxInfo.submitTaxInfo(); this.platformUtilsService.showToast("success", null, this.i18nService.t("taxInfoUpdated")); - } + }; get isCreditBalance() { return this.billing == null || this.billing.balance <= 0;