mirror of
https://github.com/bitwarden/browser
synced 2026-01-05 18:13:26 +00:00
[AC-1706] Show Discounted Prices (#6668)
* Removed subscription copy from org and individual * Discount all prices in subscription components
This commit is contained in:
@@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||
import { Subject, startWith, takeUntil } from "rxjs";
|
||||
|
||||
import { ControlsOf } from "@bitwarden/angular/types/controls-of";
|
||||
import { BillingCustomerDiscount } from "@bitwarden/common/billing/models/response/organization-subscription.response";
|
||||
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
|
||||
import { ProductType } from "@bitwarden/common/enums";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -36,6 +37,7 @@ export class SecretsManagerSubscribeComponent implements OnInit, OnDestroy {
|
||||
@Input() upgradeOrganization: boolean;
|
||||
@Input() showSubmitButton = false;
|
||||
@Input() selectedPlan: PlanResponse;
|
||||
@Input() customerDiscount: BillingCustomerDiscount;
|
||||
|
||||
logo = SecretsManagerLogo;
|
||||
productTypes = ProductType;
|
||||
@@ -63,6 +65,15 @@ export class SecretsManagerSubscribeComponent implements OnInit, OnDestroy {
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
discountPrice = (price: number) => {
|
||||
const discount =
|
||||
!!this.customerDiscount && this.customerDiscount.active
|
||||
? price * (this.customerDiscount.percentOff / 100)
|
||||
: 0;
|
||||
|
||||
return price - discount;
|
||||
};
|
||||
|
||||
get product() {
|
||||
return this.selectedPlan.product;
|
||||
}
|
||||
@@ -84,8 +95,8 @@ export class SecretsManagerSubscribeComponent implements OnInit, OnDestroy {
|
||||
|
||||
get monthlyCostPerServiceAccount() {
|
||||
return this.selectedPlan.isAnnual
|
||||
? this.selectedPlan.SecretsManager.additionalPricePerServiceAccount / 12
|
||||
: this.selectedPlan.SecretsManager.additionalPricePerServiceAccount;
|
||||
? this.discountPrice(this.selectedPlan.SecretsManager.additionalPricePerServiceAccount) / 12
|
||||
: this.discountPrice(this.selectedPlan.SecretsManager.additionalPricePerServiceAccount);
|
||||
}
|
||||
|
||||
get maxUsers() {
|
||||
@@ -98,7 +109,7 @@ export class SecretsManagerSubscribeComponent implements OnInit, OnDestroy {
|
||||
|
||||
get monthlyCostPerUser() {
|
||||
return this.selectedPlan.isAnnual
|
||||
? this.selectedPlan.SecretsManager.seatPrice / 12
|
||||
: this.selectedPlan.SecretsManager.seatPrice;
|
||||
? this.discountPrice(this.selectedPlan.SecretsManager.seatPrice) / 12
|
||||
: this.discountPrice(this.selectedPlan.SecretsManager.seatPrice);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user