From 410d1c63947a6b0220c509acd160b52c6f1a7dcf Mon Sep 17 00:00:00 2001 From: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com> Date: Sat, 13 Jul 2024 07:19:46 +0100 Subject: [PATCH] Fix the zip core error on trial initiation (#10100) --- .../trial-billing-step.component.ts | 16 ++++++------ .../billing/individual/premium.component.ts | 4 +-- .../shared/adjust-payment-dialog.component.ts | 3 ++- .../app/billing/shared/tax-info.component.ts | 26 ------------------- 4 files changed, 12 insertions(+), 37 deletions(-) diff --git a/apps/web/src/app/billing/accounts/trial-initiation/trial-billing-step.component.ts b/apps/web/src/app/billing/accounts/trial-initiation/trial-billing-step.component.ts index 2aa15b371c..24970ee1ca 100644 --- a/apps/web/src/app/billing/accounts/trial-initiation/trial-billing-step.component.ts +++ b/apps/web/src/app/billing/accounts/trial-initiation/trial-billing-step.component.ts @@ -112,7 +112,7 @@ export class TrialBillingStepComponent implements OnInit { } protected changedCountry() { - this.paymentComponent.hideBank = this.taxInfoComponent.taxInfo.country !== "US"; + this.paymentComponent.hideBank = this.taxInfoComponent.taxFormGroup.value.country !== "US"; if ( this.paymentComponent.hideBank && this.paymentComponent.method === PaymentMethodType.BankAccount @@ -206,13 +206,13 @@ export class TrialBillingStepComponent implements OnInit { private getBillingInformationFromTaxInfoComponent(): BillingInformation { return { - postalCode: this.taxInfoComponent.taxInfo.postalCode, - country: this.taxInfoComponent.taxInfo.country, - taxId: this.taxInfoComponent.taxInfo.taxId, - addressLine1: this.taxInfoComponent.taxInfo.line1, - addressLine2: this.taxInfoComponent.taxInfo.line2, - city: this.taxInfoComponent.taxInfo.city, - state: this.taxInfoComponent.taxInfo.state, + postalCode: this.taxInfoComponent.taxFormGroup?.value.postalCode, + country: this.taxInfoComponent.taxFormGroup?.value.country, + taxId: this.taxInfoComponent.taxFormGroup?.value.taxId, + addressLine1: this.taxInfoComponent.taxFormGroup?.value.line1, + addressLine2: this.taxInfoComponent.taxFormGroup?.value.line2, + city: this.taxInfoComponent.taxFormGroup?.value.city, + state: this.taxInfoComponent.taxFormGroup?.value.state, }; } diff --git a/apps/web/src/app/billing/individual/premium.component.ts b/apps/web/src/app/billing/individual/premium.component.ts index 071cefd7a5..7b1e46805b 100644 --- a/apps/web/src/app/billing/individual/premium.component.ts +++ b/apps/web/src/app/billing/individual/premium.component.ts @@ -108,8 +108,8 @@ export class PremiumComponent implements OnInit { fd.append("paymentToken", result[0]); } fd.append("additionalStorageGb", (this.additionalStorage || 0).toString()); - fd.append("country", this.taxInfoComponent.taxInfo.country); - fd.append("postalCode", this.taxInfoComponent.taxInfo.postalCode); + fd.append("country", this.taxInfoComponent?.taxFormGroup?.value.country); + fd.append("postalCode", this.taxInfoComponent?.taxFormGroup?.value.postalCode); return this.apiService.postPremium(fd); }) .then((paymentResponse) => { diff --git a/apps/web/src/app/billing/shared/adjust-payment-dialog.component.ts b/apps/web/src/app/billing/shared/adjust-payment-dialog.component.ts index 3a671491ff..1addf42629 100644 --- a/apps/web/src/app/billing/shared/adjust-payment-dialog.component.ts +++ b/apps/web/src/app/billing/shared/adjust-payment-dialog.component.ts @@ -55,8 +55,9 @@ export class AdjustPaymentDialogComponent { } submit = async () => { - if (!this.taxInfoComponent.taxFormGroup.valid) { + if (!this.taxInfoComponent?.taxFormGroup.valid && this.taxInfoComponent?.taxFormGroup.touched) { this.taxInfoComponent.taxFormGroup.markAllAsTouched(); + return; } const request = new PaymentRequest(); const response = this.paymentComponent.createPaymentToken().then((result) => { diff --git a/apps/web/src/app/billing/shared/tax-info.component.ts b/apps/web/src/app/billing/shared/tax-info.component.ts index 3f9bb23130..289c4906e9 100644 --- a/apps/web/src/app/billing/shared/tax-info.component.ts +++ b/apps/web/src/app/billing/shared/tax-info.component.ts @@ -315,17 +315,6 @@ export class TaxInfoComponent { ]; taxRates: TaxRateResponse[]; - // private pristine: TaxInfoView = { - // taxId: null, - // line1: null, - // line2: null, - // city: null, - // state: null, - // postalCode: null, - // country: "US", - // includeTaxId: false, - // }; - constructor( private apiService: ApiService, private route: ActivatedRoute, @@ -435,8 +424,6 @@ export class TaxInfoComponent { try { const taxInfo = await this.apiService.getTaxInfo(); if (taxInfo) { - // this.taxInfo.postalCode = taxInfo.postalCode; - // this.taxInfo.country = taxInfo.country || "US"; this.postalCode = taxInfo.postalCode; this.country = taxInfo.country || "US"; } @@ -451,8 +438,6 @@ export class TaxInfoComponent { this.taxFormGroup.get("postalCode").updateValueAndValidity(); } - //this.pristine = Object.assign({}, this.taxInfo); - // If not the default (US) then trigger onCountryChanged if (this.country !== "US") { this.onCountryChanged.emit(); } @@ -487,7 +472,6 @@ export class TaxInfoComponent { get taxRate() { if (this.taxRates != null) { const localTaxRate = this.taxRates.find( - //(x) => x.country === this.taxInfo.country && x.postalCode === this.taxInfo.postalCode, (x) => x.country === this.country && x.postalCode === this.postalCode, ); return localTaxRate?.rate ?? null; @@ -578,16 +562,6 @@ export class TaxInfoComponent { return this.taxSupportedCountryCodes.includes(countryCode); } - // private hasChanged(): boolean { - // for (const key in this.taxInfo) { - // // eslint-disable-next-line - // if (this.pristine.hasOwnProperty(key) && this.pristine[key] !== this.taxInfo[key]) { - // return true; - // } - // } - // return false; - // } - private taxSupportedCountryCodes: string[] = [ "CN", "FR",