1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

Update client side error handling and remove add account credit from sub (#10214)

This commit is contained in:
Alex Morask
2024-07-31 09:27:16 -04:00
committed by GitHub
parent 27fa7625cf
commit 4a0b6fc191
12 changed files with 114 additions and 105 deletions

View File

@@ -71,7 +71,7 @@ export class WebProviderService {
request.keyPair = new OrganizationKeysRequest(publicKey, encryptedPrivateKey.encryptedString);
request.collectionName = encryptedCollectionName.encryptedString;
await this.billingApiService.createClientOrganization(providerId, request);
await this.billingApiService.createProviderClientOrganization(providerId, request);
await this.apiService.refreshIdentityToken();

View File

@@ -1,7 +1,8 @@
import { DatePipe } from "@angular/common";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { Component } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { ActivatedRoute } from "@angular/router";
import { map, Subject, takeUntil } from "rxjs";
import { map } from "rxjs";
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions";
import { InvoiceResponse } from "@bitwarden/common/billing/models/response/invoices.response";
@@ -9,16 +10,23 @@ import { InvoiceResponse } from "@bitwarden/common/billing/models/response/invoi
@Component({
templateUrl: "./provider-billing-history.component.html",
})
export class ProviderBillingHistoryComponent implements OnInit, OnDestroy {
export class ProviderBillingHistoryComponent {
private providerId: string;
private destroy$ = new Subject<void>();
constructor(
private activatedRoute: ActivatedRoute,
private billingApiService: BillingApiServiceAbstraction,
private datePipe: DatePipe,
) {}
) {
this.activatedRoute.params
.pipe(
map(({ providerId }) => {
this.providerId = providerId;
}),
takeUntilDestroyed(),
)
.subscribe();
}
getClientInvoiceReport = (invoiceId: string) =>
this.billingApiService.getProviderClientInvoiceReport(this.providerId, invoiceId);
@@ -29,20 +37,4 @@ export class ProviderBillingHistoryComponent implements OnInit, OnDestroy {
};
getInvoices = async () => await this.billingApiService.getProviderInvoices(this.providerId);
ngOnInit() {
this.activatedRoute.params
.pipe(
map(({ providerId }) => {
this.providerId = providerId;
}),
takeUntil(this.destroy$),
)
.subscribe();
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
}

View File

@@ -59,7 +59,7 @@ export class ManageClientNameDialogComponent {
request.assignedSeats = this.dialogParams.organization.seats;
request.name = this.formGroup.value.name;
await this.billingApiService.updateClientOrganization(
await this.billingApiService.updateProviderClientOrganization(
this.dialogParams.providerId,
this.dialogParams.organization.id,
request,

View File

@@ -93,7 +93,7 @@ export class ManageClientSubscriptionDialogComponent implements OnInit {
request.assignedSeats = this.formGroup.value.assignedSeats;
request.name = this.dialogParams.organization.organizationName;
await this.billingApiService.updateClientOrganization(
await this.billingApiService.updateProviderClientOrganization(
this.dialogParams.provider.id,
this.dialogParams.organization.id,
request,

View File

@@ -1,9 +1,9 @@
import { Component } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { ActivatedRoute, Router } from "@angular/router";
import { firstValueFrom, from, lastValueFrom, map } from "rxjs";
import { switchMap, takeUntil } from "rxjs/operators";
import { switchMap } from "rxjs/operators";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
import { ProviderUserType } from "@bitwarden/common/admin-console/enums";
@@ -46,7 +46,6 @@ export class ManageClientsComponent extends BaseClientsComponent {
protected plans: PlanResponse[];
constructor(
private apiService: ApiService,
private billingApiService: BillingApiService,
private configService: ConfigService,
private providerService: ProviderService,
@@ -68,9 +67,7 @@ export class ManageClientsComponent extends BaseClientsComponent {
validationService,
webProviderService,
);
}
ngOnInit() {
this.activatedRoute.parent.params
.pipe(
switchMap((params) => {
@@ -90,15 +87,11 @@ export class ManageClientsComponent extends BaseClientsComponent {
}),
);
}),
takeUntil(this.destroy$),
takeUntilDestroyed(),
)
.subscribe();
}
ngOnDestroy() {
super.ngOnDestroy();
}
removeMonthly = (plan: string) => plan.replace(" (Monthly)", "");
async load() {
@@ -106,7 +99,9 @@ export class ManageClientsComponent extends BaseClientsComponent {
this.isProviderAdmin = this.provider.type === ProviderUserType.ProviderAdmin;
this.clients = (await this.apiService.getProviderClients(this.providerId)).data;
this.clients = (
await this.billingApiService.getProviderClientOrganizations(this.providerId)
).data;
this.dataSource.data = this.clients;

View File

@@ -69,9 +69,6 @@
</h2>
<p class="tw-text-lg tw-font-bold">{{ subscription.accountCredit | currency: "$" }}</p>
<p bitTypography="body1">{{ "creditAppliedDesc" | i18n }}</p>
<button type="button" bitButton buttonType="secondary" [bitAction]="addAccountCredit">
{{ "addCredit" | i18n }}
</button>
</ng-container>
<!-- Tax Information -->
<ng-container>

View File

@@ -2,7 +2,6 @@ import { Component } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { Subject, concatMap, takeUntil } from "rxjs";
import { openAddAccountCreditDialog } from "@bitwarden/angular/billing/components";
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions/billilng-api.service.abstraction";
import { TaxInformation } from "@bitwarden/common/billing/models/domain";
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
@@ -11,7 +10,7 @@ import {
ProviderSubscriptionResponse,
} from "@bitwarden/common/billing/models/response/provider-subscription-response";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { DialogService, ToastService } from "@bitwarden/components";
import { ToastService } from "@bitwarden/components";
@Component({
selector: "app-provider-subscription",
@@ -27,9 +26,10 @@ export class ProviderSubscriptionComponent {
totalCost: number;
currentDate = new Date();
protected readonly TaxInformation = TaxInformation;
constructor(
private billingApiService: BillingApiServiceAbstraction,
private dialogService: DialogService,
private i18nService: I18nService,
private route: ActivatedRoute,
private toastService: ToastService,
@@ -63,13 +63,6 @@ export class ProviderSubscriptionComponent {
this.loading = false;
}
addAccountCredit = () =>
openAddAccountCreditDialog(this.dialogService, {
data: {
providerId: this.providerId,
},
});
updateTaxInformation = async (taxInformation: TaxInformation) => {
const request = ExpandedTaxInfoUpdateRequest.From(taxInformation);
await this.billingApiService.updateProviderTaxInformation(this.providerId, request);
@@ -108,6 +101,4 @@ export class ProviderSubscriptionComponent {
this.destroy$.next();
this.destroy$.complete();
}
protected readonly TaxInformation = TaxInformation;
}