1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 06:43:35 +00:00

Make provider discount dynamic in provider portal (#9831)

This commit is contained in:
Alex Morask
2024-06-26 09:33:26 -04:00
committed by GitHub
parent dbc6f1c840
commit c85429ab4f
3 changed files with 13 additions and 6 deletions

View File

@@ -7,7 +7,9 @@
<p>{{ "createNewClientToManageAsProvider" | i18n }}</p> <p>{{ "createNewClientToManageAsProvider" | i18n }}</p>
<div class="tw-mb-3"> <div class="tw-mb-3">
<span class="tw-text-lg tw-pr-1">{{ "selectAPlan" | i18n }}</span> <span class="tw-text-lg tw-pr-1">{{ "selectAPlan" | i18n }}</span>
<span bitBadge variant="success">{{ "thirtyFivePercentDiscount" | i18n }}</span> <span *ngIf="this.discountPercentage" bitBadge variant="success">{{
"providerDiscount" | i18n: this.discountPercentage
}}</span>
</div> </div>
<ng-container> <ng-container>
<div class="tw-grid tw-grid-flow-col tw-grid-cols-2 tw-gap-4 tw-mb-4"> <div class="tw-grid tw-grid-flow-col tw-grid-cols-2 tw-gap-4 tw-mb-4">

View File

@@ -42,6 +42,7 @@ type PlanCard = {
templateUrl: "./create-client-dialog.component.html", templateUrl: "./create-client-dialog.component.html",
}) })
export class CreateClientDialogComponent implements OnInit { export class CreateClientDialogComponent implements OnInit {
protected discountPercentage: number;
protected formGroup = new FormGroup({ protected formGroup = new FormGroup({
clientOwnerEmail: new FormControl<string>("", [Validators.required, Validators.email]), clientOwnerEmail: new FormControl<string>("", [Validators.required, Validators.email]),
organizationName: new FormControl<string>("", [Validators.required]), organizationName: new FormControl<string>("", [Validators.required]),
@@ -96,27 +97,31 @@ export class CreateClientDialogComponent implements OnInit {
} }
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
const subscription = await this.billingApiService.getProviderSubscription( const response = await this.billingApiService.getProviderSubscription(
this.dialogParams.providerId, this.dialogParams.providerId,
); );
this.providerPlans = subscription?.plans ?? [];
this.providerPlans = response?.plans ?? [];
const teamsPlan = this.dialogParams.plans.find((plan) => plan.type === PlanType.TeamsMonthly); const teamsPlan = this.dialogParams.plans.find((plan) => plan.type === PlanType.TeamsMonthly);
const enterprisePlan = this.dialogParams.plans.find( const enterprisePlan = this.dialogParams.plans.find(
(plan) => plan.type === PlanType.EnterpriseMonthly, (plan) => plan.type === PlanType.EnterpriseMonthly,
); );
this.discountPercentage = response.discountPercentage;
const discountFactor = this.discountPercentage ? (100 - this.discountPercentage) / 100 : 1;
this.planCards = [ this.planCards = [
{ {
name: this.i18nService.t("planNameTeams"), name: this.i18nService.t("planNameTeams"),
cost: teamsPlan.PasswordManager.providerPortalSeatPrice * 0.65, // 35% off for MSPs, cost: teamsPlan.PasswordManager.providerPortalSeatPrice * discountFactor,
type: teamsPlan.type, type: teamsPlan.type,
plan: teamsPlan, plan: teamsPlan,
selected: true, selected: true,
}, },
{ {
name: this.i18nService.t("planNameEnterprise"), name: this.i18nService.t("planNameEnterprise"),
cost: enterprisePlan.PasswordManager.providerPortalSeatPrice * 0.65, // 35% off for MSPs, cost: enterprisePlan.PasswordManager.providerPortalSeatPrice * discountFactor,
type: enterprisePlan.type, type: enterprisePlan.type,
plan: enterprisePlan, plan: enterprisePlan,
selected: false, selected: false,

View File

@@ -41,7 +41,7 @@
{{ ((100 - subscription.discountPercentage) / 100) * i.cost | currency: "$" }} /{{ {{ ((100 - subscription.discountPercentage) / 100) * i.cost | currency: "$" }} /{{
"month" | i18n "month" | i18n
}} }}
<div> <div *ngIf="subscription.discountPercentage">
<bit-hint class="tw-text-sm tw-line-through"> <bit-hint class="tw-text-sm tw-line-through">
{{ i.cost | currency: "$" }} /{{ "month" | i18n }} {{ i.cost | currency: "$" }} /{{ "month" | i18n }}
</bit-hint> </bit-hint>