Updated portal preview in tier modal

refs 9e43fa9332

- cleans up free trial logic in portal preview
This commit is contained in:
Rishabh 2022-08-08 17:57:02 +05:30
parent e1984c8607
commit 800a2ee3d7
2 changed files with 14 additions and 14 deletions

View File

@ -219,12 +219,10 @@
<span class="amount">0</span>
</div>
{{else}}
{{#if (feature 'freeTrial')}}
{{#if this.freeTrialEnabled}}
{{#if this.isFreeTierEnabled}}
<div class="gh-portal-tier-price">
<span class="amount">{{ this.trialDays }} days free</span>
<span class="amount">{{ this.tier.trialDays }} days free</span>
</div>
{{/if}}
{{/if}}
{{#if this.stripeYearlyAmount}}
{{#if (feature 'freeTrial')}}
@ -274,16 +272,14 @@
{{/if}}
{{/if}}
</div>
{{#if (feature 'freeTrial')}}
{{#if this.freeTrialEnabled}}
<span class="after-trial-amount">Then
{{#if (eq this.previewCadence "yearly")}}
{{currency-symbol this.currency}}{{ format-number this.stripeYearlyAmount }}/year
{{else}}
{{currency-symbol this.currency}}{{ format-number this.stripeMonthlyAmount }}/month
{{/if}}
</span>
{{#if this.isFreeTrialEnabled}}
<span class="after-trial-amount">Then
{{#if (eq this.previewCadence "yearly")}}
{{currency-symbol this.currency}}{{ format-number this.stripeYearlyAmount }}/year
{{else}}
{{currency-symbol this.currency}}{{ format-number this.stripeMonthlyAmount }}/month
{{/if}}
</span>
{{/if}}
</div>

View File

@ -21,6 +21,7 @@ const CURRENCIES = currencies.map((currency) => {
// TODO: update modals to work fully with Glimmer components
@classic
export default class ModalTierPrice extends ModalBase {
@service feature;
@service settings;
@service config;
@tracked model;
@ -61,6 +62,10 @@ export default class ModalTierPrice extends ModalBase {
return CURRENCIES.findBy('value', this.currency);
}
get isFreeTierEnabled() {
return this.feature.get('freeTrial') && this.freeTrialEnabled && this.tier.get('trialDays') > 0;
}
init() {
super.init(...arguments);
this.tier = this.model.tier;
@ -82,7 +87,6 @@ export default class ModalTierPrice extends ModalBase {
this.calculateDiscount();
if (this.tier.get('trialDays')) {
this.freeTrialEnabled = true;
this.trialDays = this.tier.get('trialDays');
}
this.accentColorStyle = htmlSafe(`color: ${this.settings.get('accentColor')}`);
}