From 0134bbf4efa0bc270539be36da94f8533d90e1ca Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Thu, 28 Jul 2022 16:37:38 -0700 Subject: [PATCH] [EC-8] Remove org payment method component --- .../billing/organization-billing.module.ts | 3 - ...organization-payment-method.component.html | 165 ------------------ .../organization-payment-method.component.ts | 158 ----------------- 3 files changed, 326 deletions(-) delete mode 100644 apps/web/src/app/modules/organizations/billing/organization-payment-method.component.html delete mode 100644 apps/web/src/app/modules/organizations/billing/organization-payment-method.component.ts diff --git a/apps/web/src/app/modules/organizations/billing/organization-billing.module.ts b/apps/web/src/app/modules/organizations/billing/organization-billing.module.ts index 60b20b0623e..7898512486c 100644 --- a/apps/web/src/app/modules/organizations/billing/organization-billing.module.ts +++ b/apps/web/src/app/modules/organizations/billing/organization-billing.module.ts @@ -5,7 +5,6 @@ import { SharedModule } from "../../shared.module"; import { BillingSyncApiKeyComponent } from "./billing-sync-api-key.component"; import { OrganizationBillingTabComponent } from "./organization-billing-tab.component"; -import { OrganizationPaymentMethodComponent } from "./organization-payment-method.component"; import { OrganizationSubscriptionComponent } from "./organization-subscription.component"; @NgModule({ @@ -13,13 +12,11 @@ import { OrganizationSubscriptionComponent } from "./organization-subscription.c declarations: [ BillingSyncApiKeyComponent, OrganizationBillingTabComponent, - OrganizationPaymentMethodComponent, OrganizationSubscriptionComponent, ], exports: [ BillingSyncApiKeyComponent, OrganizationBillingTabComponent, - OrganizationPaymentMethodComponent, OrganizationSubscriptionComponent, ], }) diff --git a/apps/web/src/app/modules/organizations/billing/organization-payment-method.component.html b/apps/web/src/app/modules/organizations/billing/organization-payment-method.component.html deleted file mode 100644 index 2b44a4d8242..00000000000 --- a/apps/web/src/app/modules/organizations/billing/organization-payment-method.component.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - {{ "loading" | i18n }} - - -

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

-

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

-

{{ "creditAppliedDesc" | i18n }}

- - - - -

{{ "paymentMethod" | i18n }}

-

{{ "noPaymentMethod" | i18n }}

- - -

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

-
- -
-
-
$0.
-
- -
- -
-
-
$0.
-
- -
- -
-
-

- - {{ "inAppPurchase" | i18n }} - {{ paymentSource.description }} -

-
- - - - -

{{ "taxInformation" | i18n }}

-

{{ "taxInformationDesc" | i18n }}

-
- - {{ "loading" | i18n }} -
-
- - -
-
diff --git a/apps/web/src/app/modules/organizations/billing/organization-payment-method.component.ts b/apps/web/src/app/modules/organizations/billing/organization-payment-method.component.ts deleted file mode 100644 index b199b25bbb7..00000000000 --- a/apps/web/src/app/modules/organizations/billing/organization-payment-method.component.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { Component, OnInit, ViewChild } from "@angular/core"; -import { ActivatedRoute } from "@angular/router"; - -import { ApiService } from "@bitwarden/common/abstractions/api.service"; -import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; -import { LogService } from "@bitwarden/common/abstractions/log.service"; -import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service"; -import { PaymentMethodType } from "@bitwarden/common/enums/paymentMethodType"; -import { VerifyBankRequest } from "@bitwarden/common/models/request/verifyBankRequest"; -import { BillingResponse } from "@bitwarden/common/models/response/billingResponse"; -import { OrganizationResponse } from "@bitwarden/common/models/response/organizationResponse"; - -import { TaxInfoComponent } from "src/app/settings/tax-info.component"; - -@Component({ - selector: "app-org-payment-method", - templateUrl: "./organization-payment-method.component.html", -}) -export class OrganizationPaymentMethodComponent implements OnInit { - @ViewChild(TaxInfoComponent) taxInfo: TaxInfoComponent; - - loading = false; - firstLoaded = false; - showAdjustPayment = false; - showAddCredit = false; - billing: BillingResponse; - org: OrganizationResponse; - paymentMethodType = PaymentMethodType; - organizationId: string; - verifyAmount1: number; - verifyAmount2: number; - - verifyBankPromise: Promise; - taxFormPromise: Promise; - - constructor( - private apiService: ApiService, - private i18nService: I18nService, - private route: ActivatedRoute, - private platformUtilsService: PlatformUtilsService, - private logService: LogService - ) {} - - async ngOnInit() { - this.route.parent.parent.params.subscribe(async (params) => { - this.organizationId = params.organizationId; - await this.load(); - this.firstLoaded = true; - }); - } - - async load() { - if (this.loading) { - return; - } - this.loading = true; - if (this.organizationId != null) { - const billingPromise = this.apiService.getOrganizationBilling(this.organizationId); - const orgPromise = this.apiService.getOrganization(this.organizationId); - - [this.billing, this.org] = await Promise.all([billingPromise, orgPromise]); - } - this.loading = false; - } - - async verifyBank() { - if (this.loading) { - return; - } - - try { - const request = new VerifyBankRequest(); - request.amount1 = this.verifyAmount1; - request.amount2 = this.verifyAmount2; - this.verifyBankPromise = this.apiService.postOrganizationVerifyBank( - this.organizationId, - request - ); - await this.verifyBankPromise; - this.platformUtilsService.showToast( - "success", - null, - this.i18nService.t("verifiedBankAccount") - ); - this.load(); - } catch (e) { - this.logService.error(e); - } - } - - async submitTaxInfo() { - this.taxFormPromise = this.taxInfo.submitTaxInfo(); - await this.taxFormPromise; - this.platformUtilsService.showToast("success", null, this.i18nService.t("taxInfoUpdated")); - } - - addCredit() { - if (this.paymentSourceInApp) { - this.platformUtilsService.showDialog( - this.i18nService.t("cannotPerformInAppPurchase"), - this.i18nService.t("addCredit"), - null, - null, - "warning" - ); - return; - } - this.showAddCredit = true; - } - - closeAddCredit(load: boolean) { - this.showAddCredit = false; - if (load) { - this.load(); - } - } - - changePayment() { - if (this.paymentSourceInApp) { - this.platformUtilsService.showDialog( - this.i18nService.t("cannotPerformInAppPurchase"), - this.i18nService.t("changePaymentMethod"), - null, - null, - "warning" - ); - return; - } - this.showAdjustPayment = true; - } - - closePayment(load: boolean) { - this.showAdjustPayment = false; - if (load) { - this.load(); - } - } - - get isCreditBalance() { - return this.billing == null || this.billing.balance <= 0; - } - - get creditOrBalance() { - return Math.abs(this.billing != null ? this.billing.balance : 0); - } - - get paymentSource() { - return this.billing != null ? this.billing.paymentSource : null; - } - - get paymentSourceInApp() { - return ( - this.paymentSource != null && - (this.paymentSource.type === PaymentMethodType.AppleInApp || - this.paymentSource.type === PaymentMethodType.GoogleInApp) - ); - } -}