Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Fix basePrice to reflect the sponsorship (#1311)
Browse files Browse the repository at this point in the history
* Fix basePrice to reflect the sponsorship

* Ran linter

* Add latest copy

* Remove unneeded if

* Fix times

* Stopped hardcoding basePrice

* Stopped hardcoding 40 in UI

* Switch to single small block

* Update jslib

* Revert "Update jslib"

This reverts commit 28534f2.

* Revert "Remove unneeded if"

This reverts commit 5540b19.

* Fix revert issue

(cherry picked from commit 4b856d9)
  • Loading branch information
justindbaur committed Nov 24, 2021
1 parent e54586c commit 23048d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
12 changes: 9 additions & 3 deletions src/app/settings/organization-plans.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h2 class="mt-5">{{'chooseYourPlan' | i18n}}</h2>
</small>
</ng-template>
<span *ngIf="selectableProduct.product != productTypes.Free">
<ng-container *ngIf="selectableProduct.basePrice">
<ng-container *ngIf="selectableProduct.basePrice && !acceptingSponsorship">
{{selectableProduct.basePrice / 12 | currency:'$'}} /{{'month' | i18n}},
{{'includesXUsers' | i18n : selectableProduct.baseSeats}}
<ng-container *ngIf="selectableProduct.hasAdditionalSeatsOption">
Expand Down Expand Up @@ -162,8 +162,14 @@ <h2 class="spaced-header">{{'summary' | i18n}}</h2>
{{'basePrice' | i18n}}: {{ selectablePlan.basePrice / 12 | currency:'$'}} &times; 12
{{'monthAbbr' | i18n}}
=
{{selectablePlan.basePrice | currency:'$'}}
/{{'year' | i18n}}
<ng-container *ngIf="acceptingSponsorship; else notAcceptingSponsorship">
<span style="text-decoration: line-through;">{{selectablePlan.basePrice | currency:'$'}}</span>
{{'freeWithSponsorship' | i18n}}
</ng-container>
<ng-template #notAcceptingSponsorship>
{{selectablePlan.basePrice | currency:'$'}}
/{{'year' | i18n}}
</ng-template>
</small>
<small *ngIf="selectablePlan.hasAdditionalSeatsOption">
<span *ngIf="selectablePlan.baseSeats">{{'additionalUsers' | i18n}}:</span>
Expand Down
19 changes: 12 additions & 7 deletions src/app/settings/organization-plans.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class OrganizationPlansComponent implements OnInit {
productTypes = ProductType;
formPromise: Promise<any>;
singleOrgPolicyBlock: boolean = false;
discount = 0;

plans: PlanResponse[];

Expand Down Expand Up @@ -120,15 +121,19 @@ export class OrganizationPlansComponent implements OnInit {
validPlans = validPlans.filter(plan => plan.product !== ProductType.Free);
}

validPlans = validPlans
.filter(plan => !plan.legacyYear
&& !plan.disabled
&& (plan.isAnnual || plan.product === this.productTypes.Free));

if (this.acceptingSponsorship) {
validPlans = validPlans.filter(plan => plan.product === ProductType.Families);
const familyPlan = this.plans.find(plan => plan.type === PlanType.FamiliesAnnually);
this.discount = familyPlan.basePrice;
validPlans = [
familyPlan,
];
}

validPlans = validPlans
.filter(plan => !plan.legacyYear
&& !plan.disabled
&& (plan.isAnnual || plan.product === this.productTypes.Free));

return validPlans;
}

Expand Down Expand Up @@ -177,7 +182,7 @@ export class OrganizationPlansComponent implements OnInit {
if (this.selectedPlan.hasPremiumAccessOption && this.premiumAccessAddon) {
subTotal += this.selectedPlan.premiumAccessOptionPrice;
}
return subTotal;
return subTotal - this.discount;
}

get freeTrial() {
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4730,5 +4730,8 @@
},
"sponsorshipTokenHasExpired": {
"message": "The sponsorship offer has expired."
},
"freeWithSponsorship": {
"message": "FREE with sponsorship"
}
}

0 comments on commit 23048d4

Please sign in to comment.