1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

PM-5022 Migrate Payment Method component (#8397)

* PM-5022 Migrated Payment Method component

* PM-5022 Addressed review comments

* PM-5022 Addressed review comments on CSS

* PM-5022 Addressed the css comment and fixed build issues

* PM-5022 Changed app-callout to bit-callout

---------

Co-authored-by: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com>
This commit is contained in:
KiruthigaManivannan
2024-06-26 19:36:25 +05:30
committed by GitHub
parent c85429ab4f
commit 5e9e095b40
2 changed files with 84 additions and 119 deletions

View File

@@ -38,9 +38,6 @@ export class PaymentMethodComponent implements OnInit {
organizationId: string;
isUnpaid = false;
verifyBankPromise: Promise<any>;
taxFormPromise: Promise<any>;
verifyBankForm = this.formBuilder.group({
amount1: new FormControl<number>(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;