1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-20 03:13:55 +00:00
This commit is contained in:
Jonas Hendrickx
2024-11-20 19:37:01 +01:00
parent 2af08b81e2
commit 2117d52148
5 changed files with 49 additions and 107 deletions

View File

@@ -26,6 +26,8 @@ export class ManageTaxInformationComponent implements OnInit, OnDestroy {
state: "",
});
isTaxSupported: boolean;
private destroy$ = new Subject<void>();
protected readonly countries: CountryListItem[] = this.taxService.getCountries();
@@ -61,7 +63,7 @@ export class ManageTaxInformationComponent implements OnInit, OnDestroy {
this.formGroup.patchValue({
...this.startWith,
includeTaxId:
this.countrySupportsTax(this.startWith.country) &&
this.isTaxSupported &&
(!!this.startWith.taxId ||
!!this.startWith.line1 ||
!!this.startWith.line2 ||
@@ -81,7 +83,13 @@ export class ManageTaxInformationComponent implements OnInit, OnDestroy {
city: values.city,
state: values.state,
};
this.taxService
.isCountrySupported(this.taxInformation.country)
.then((isSupported) => (this.isTaxSupported = isSupported))
.catch(() => (this.isTaxSupported = false));
});
this.isTaxSupported = await this.taxService.isCountrySupported(this.taxInformation.country);
}
ngOnDestroy() {
@@ -89,17 +97,11 @@ export class ManageTaxInformationComponent implements OnInit, OnDestroy {
this.destroy$.complete();
}
protected countrySupportsTax(countryCode: string) {
return this.taxService.getSupportedCountries().includes(countryCode);
}
protected get includeTaxIdIsSelected() {
return this.formGroup.value.includeTaxId;
}
protected get selectionSupportsAdditionalOptions() {
return (
this.formGroup.value.country !== "US" && this.countrySupportsTax(this.formGroup.value.country)
);
return this.formGroup.value.country !== "US" && this.isTaxSupported;
}
}