From 425c7914b0673d33e69ef8cce2c78e42915acba5 Mon Sep 17 00:00:00 2001 From: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com> Date: Mon, 6 May 2024 20:21:11 +0100 Subject: [PATCH] [AC-2558] Provider Admin still sees manage billing options - not the provided image (#9048) * Fix the issue of provider admin not seeing the image * Resolve the case and ternary operator comment --- ...ganization-subscription-cloud.component.html | 2 +- ...organization-subscription-cloud.component.ts | 17 +++++++++-------- .../response/provider/provider.response.ts | 3 +++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html index 38903bab19..306c8dbc26 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html @@ -256,7 +256,7 @@ - +
diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts index 7acb108808..198332db0c 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts @@ -5,6 +5,7 @@ import { concatMap, firstValueFrom, lastValueFrom, Observable, Subject, takeUnti import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; +import { ProviderApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/provider/provider-api.service.abstraction"; import { OrganizationApiKeyType, ProviderType } from "@bitwarden/common/admin-console/enums"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { PlanType } from "@bitwarden/common/billing/enums"; @@ -49,7 +50,7 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy locale: string; showUpdatedSubscriptionStatusSection$: Observable; manageBillingFromProviderPortal = ManageBilling; - IsProviderManaged = false; + isProviderManaged = false; protected readonly teamsStarter = ProductType.TeamsStarter; @@ -69,6 +70,7 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy private route: ActivatedRoute, private dialogService: DialogService, private configService: ConfigService, + private providerService: ProviderApiServiceAbstraction, ) {} async ngOnInit() { @@ -106,13 +108,12 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy this.loading = true; this.locale = await firstValueFrom(this.i18nService.locale$); this.userOrg = await this.organizationService.get(this.organizationId); - const enableConsolidatedBilling = await firstValueFrom(this.enableConsolidatedBilling$); - this.IsProviderManaged = - this.userOrg.hasProvider && - this.userOrg.providerType == ProviderType.Msp && - enableConsolidatedBilling - ? true - : false; + if (this.userOrg.hasProvider) { + const provider = await this.providerService.getProvider(this.userOrg.providerId); + const enableConsolidatedBilling = await firstValueFrom(this.enableConsolidatedBilling$); + this.isProviderManaged = provider.type == ProviderType.Msp && enableConsolidatedBilling; + } + if (this.userOrg.canViewSubscription) { this.sub = await this.organizationApiService.getSubscription(this.organizationId); this.lineItems = this.sub?.subscription?.items; diff --git a/libs/common/src/admin-console/models/response/provider/provider.response.ts b/libs/common/src/admin-console/models/response/provider/provider.response.ts index 0ea925cd33..369499595c 100644 --- a/libs/common/src/admin-console/models/response/provider/provider.response.ts +++ b/libs/common/src/admin-console/models/response/provider/provider.response.ts @@ -1,4 +1,5 @@ import { BaseResponse } from "../../../../models/response/base.response"; +import { ProviderType } from "../../../enums"; export class ProviderResponse extends BaseResponse { id: string; @@ -6,6 +7,7 @@ export class ProviderResponse extends BaseResponse { businessName: string; billingEmail: string; creationDate: Date; + type: ProviderType; constructor(response: any) { super(response); @@ -14,5 +16,6 @@ export class ProviderResponse extends BaseResponse { this.businessName = this.getResponseProperty("BusinessName"); this.billingEmail = this.getResponseProperty("BillingEmail"); this.creationDate = this.getResponseProperty("CreationDate"); + this.type = this.getResponseProperty("Type"); } }