1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00

[AC-1944] Add provider billing history component (#9520)

* Add provider-billing-history.component

* Implement provider client invoice export
This commit is contained in:
Alex Morask
2024-06-14 12:27:49 -04:00
committed by GitHub
parent 215bbc2f8e
commit af53df09ac
15 changed files with 270 additions and 0 deletions

View File

@@ -34,6 +34,7 @@
>
<bit-nav-item [text]="'subscription' | i18n" route="billing/subscription"></bit-nav-item>
<bit-nav-item [text]="'paymentMethod' | i18n" route="billing/payment-method"></bit-nav-item>
<bit-nav-item [text]="'billingHistory' | i18n" route="billing/history"></bit-nav-item>
</bit-nav-group>
<bit-nav-item
icon="bwi-cogs"

View File

@@ -13,6 +13,7 @@ import {
ProviderSubscriptionComponent,
hasConsolidatedBilling,
ProviderPaymentMethodComponent,
ProviderBillingHistoryComponent,
} from "../../billing/providers";
import { ClientsComponent } from "./clients/clients.component";
@@ -139,6 +140,13 @@ const routes: Routes = [
titleId: "paymentMethod",
},
},
{
path: "history",
component: ProviderBillingHistoryComponent,
data: {
titleId: "billingHistory",
},
},
],
},
{

View File

@@ -15,6 +15,7 @@ import {
ManageClientOrganizationNameComponent,
ManageClientOrganizationsComponent,
ManageClientOrganizationSubscriptionComponent,
ProviderBillingHistoryComponent,
ProviderPaymentMethodComponent,
ProviderSelectPaymentMethodDialogComponent,
ProviderSubscriptionComponent,
@@ -70,6 +71,7 @@ import { SetupComponent } from "./setup/setup.component";
ManageClientOrganizationsComponent,
ManageClientOrganizationNameComponent,
ManageClientOrganizationSubscriptionComponent,
ProviderBillingHistoryComponent,
ProviderSubscriptionComponent,
ProviderSelectPaymentMethodDialogComponent,
ProviderPaymentMethodComponent,

View File

@@ -0,0 +1,9 @@
<app-header></app-header>
<bit-container>
<h3 bitTypography="h3">{{ "invoices" | i18n }}</h3>
<app-invoices
[getInvoices]="getInvoices"
[getClientInvoiceReport]="getClientInvoiceReport"
[getClientInvoiceReportName]="getClientInvoiceReportName"
></app-invoices>
</bit-container>

View File

@@ -0,0 +1,48 @@
import { DatePipe } from "@angular/common";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { map, Subject, takeUntil } from "rxjs";
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions";
import { InvoiceResponse } from "@bitwarden/common/billing/models/response/invoices.response";
@Component({
templateUrl: "./provider-billing-history.component.html",
})
export class ProviderBillingHistoryComponent implements OnInit, OnDestroy {
private providerId: string;
private destroy$ = new Subject<void>();
constructor(
private activatedRoute: ActivatedRoute,
private billingApiService: BillingApiServiceAbstraction,
private datePipe: DatePipe,
) {}
getClientInvoiceReport = (invoiceId: string) =>
this.billingApiService.getProviderClientInvoiceReport(this.providerId, invoiceId);
getClientInvoiceReportName = (invoice: InvoiceResponse) => {
const date = this.datePipe.transform(invoice.date, "yyyyMMdd");
return `bitwarden_provider_${date}_${invoice.number}`;
};
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

@@ -1,3 +1,4 @@
export * from "./billing-history/provider-billing-history.component";
export * from "./clients";
export * from "./guards/has-consolidated-billing.guard";
export * from "./payment-method/provider-select-payment-method-dialog.component";