mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
Add tax information to provider setup component when FF is on. (#8616)
This commit is contained in:
@@ -4,7 +4,7 @@ import { FormsModule } from "@angular/forms";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { SearchModule } from "@bitwarden/components";
|
||||
import { OrganizationPlansComponent } from "@bitwarden/web-vault/app/billing";
|
||||
import { OrganizationPlansComponent, TaxInfoComponent } from "@bitwarden/web-vault/app/billing";
|
||||
import { PaymentMethodWarningsModule } from "@bitwarden/web-vault/app/billing/shared";
|
||||
import { OssModule } from "@bitwarden/web-vault/app/oss.module";
|
||||
|
||||
@@ -39,6 +39,7 @@ import { SetupComponent } from "./setup/setup.component";
|
||||
SearchModule,
|
||||
ProvidersLayoutComponent,
|
||||
PaymentMethodWarningsModule,
|
||||
TaxInfoComponent,
|
||||
],
|
||||
declarations: [
|
||||
AcceptProviderComponent,
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div *ngIf="enableConsolidatedBilling$ | async" class="form-group col-12">
|
||||
<app-tax-info />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Component, OnInit, ViewChild } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import { first } from "rxjs/operators";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { ProviderSetupRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-setup.request";
|
||||
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||
@@ -12,6 +14,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||
import { ProviderKey } from "@bitwarden/common/types/key";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { TaxInfoComponent } from "@bitwarden/web-vault/app/billing";
|
||||
|
||||
@Component({
|
||||
selector: "provider-setup",
|
||||
@@ -19,6 +22,8 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
|
||||
})
|
||||
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
||||
export class SetupComponent implements OnInit {
|
||||
@ViewChild(TaxInfoComponent) taxInfoComponent: TaxInfoComponent;
|
||||
|
||||
loading = true;
|
||||
authed = false;
|
||||
email: string;
|
||||
@@ -34,6 +39,11 @@ export class SetupComponent implements OnInit {
|
||||
false,
|
||||
);
|
||||
|
||||
protected enableConsolidatedBilling$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.EnableConsolidatedBilling,
|
||||
false,
|
||||
);
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
@@ -102,6 +112,22 @@ export class SetupComponent implements OnInit {
|
||||
request.token = this.token;
|
||||
request.key = key;
|
||||
|
||||
const enableConsolidatedBilling = await firstValueFrom(this.enableConsolidatedBilling$);
|
||||
|
||||
if (enableConsolidatedBilling) {
|
||||
request.taxInfo = new ExpandedTaxInfoUpdateRequest();
|
||||
const taxInfoView = this.taxInfoComponent.taxInfo;
|
||||
request.taxInfo.country = taxInfoView.country;
|
||||
request.taxInfo.postalCode = taxInfoView.postalCode;
|
||||
if (taxInfoView.includeTaxId) {
|
||||
request.taxInfo.taxId = taxInfoView.taxId;
|
||||
request.taxInfo.line1 = taxInfoView.line1;
|
||||
request.taxInfo.line2 = taxInfoView.line2;
|
||||
request.taxInfo.city = taxInfoView.city;
|
||||
request.taxInfo.state = taxInfoView.state;
|
||||
}
|
||||
}
|
||||
|
||||
const provider = await this.apiService.postProviderSetup(this.providerId, request);
|
||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("providerSetup"));
|
||||
await this.syncService.fullSync(true);
|
||||
|
||||
Reference in New Issue
Block a user