Skip to content

Commit

Permalink
Revert "remove"
Browse files Browse the repository at this point in the history
This reverts commit f0413bd.
  • Loading branch information
jonashendrickx committed Nov 28, 2024
1 parent f0413bd commit 974e070
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,20 @@ <h2 bitTypography="h2">{{ "paymentMethod" | i18n }}</h2>
{{ "paymentChargedWithUnpaidSubscription" | i18n }}
</p>
</bit-section>
<!-- Tax Information -->
<bit-section>
<h2 bitTypography="h2">{{ "taxInformation" | i18n }}</h2>
<p bitTypography="body1">{{ "taxInformationDesc" | i18n }}</p>
<app-tax-info></app-tax-info>
<button
type="button"
bitButton
bitFormButton
buttonType="primary"
[bitAction]="updateTaxInformation"
>
{{ "save" | i18n }}
</button>
</bit-section>
</ng-container>
</bit-container>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Location } from "@angular/common";
import { Component, OnDestroy } from "@angular/core";
import { Component, OnDestroy, ViewChild } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { ActivatedRoute, Router } from "@angular/router";
import { from, lastValueFrom, switchMap } from "rxjs";
Expand All @@ -9,6 +9,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions";
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
import { VerifyBankAccountRequest } from "@bitwarden/common/billing/models/request/verify-bank-account.request";
import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/models/response/organization-subscription.response";
import { PaymentSourceResponse } from "@bitwarden/common/billing/models/response/payment-source.response";
Expand All @@ -19,6 +20,7 @@ import { DialogService, ToastService } from "@bitwarden/components";

import { FreeTrial } from "../../../core/types/free-trial";
import { TrialFlowService } from "../../services/trial-flow.service";
import { TaxInfoComponent } from "../../shared";
import {
AddCreditDialogResult,
openAddCreditDialog,
Expand All @@ -32,6 +34,8 @@ import {
templateUrl: "./organization-payment-method.component.html",
})
export class OrganizationPaymentMethodComponent implements OnDestroy {
@ViewChild(TaxInfoComponent) taxInfoComponent: TaxInfoComponent;

organizationId: string;
isUnpaid = false;
accountCredit: number;
Expand Down Expand Up @@ -177,6 +181,32 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
}
};

protected updateTaxInformation = async (): Promise<void> => {
this.taxInfoComponent.taxFormGroup.updateValueAndValidity();
this.taxInfoComponent.taxFormGroup.markAllAsTouched();

if (this.taxInfoComponent.taxFormGroup.invalid) {
return;
}

const request = new ExpandedTaxInfoUpdateRequest();
request.country = this.taxInfoComponent.country;
request.postalCode = this.taxInfoComponent.postalCode;
request.taxId = this.taxInfoComponent.taxId;
request.line1 = this.taxInfoComponent.line1;
request.line2 = this.taxInfoComponent.line2;
request.city = this.taxInfoComponent.city;
request.state = this.taxInfoComponent.state;

await this.billingApiService.updateOrganizationTaxInformation(this.organizationId, request);

this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("taxInfoUpdated"),
});
};

protected verifyBankAccount = async (request: VerifyBankAccountRequest): Promise<void> => {
await this.billingApiService.verifyOrganizationBankAccount(this.organizationId, request);
this.toastService.showToast({
Expand Down

0 comments on commit 974e070

Please sign in to comment.