diff --git a/ghost/admin/app/controllers/offer.js b/ghost/admin/app/controllers/offer.js index 22277fd5f1..3f674613b2 100644 --- a/ghost/admin/app/controllers/offer.js +++ b/ghost/admin/app/controllers/offer.js @@ -82,6 +82,14 @@ export default class OffersController extends Controller { }; } + get isTrialOffer() { + return this.offer?.type === 'trial'; + } + + get isDiscountOffer() { + return this.offer?.type !== 'trial'; + } + get cadence() { if (this.offer.tier && this.offer.cadence) { const tier = this.tiers.findBy('id', this.offer.tier.id); @@ -312,6 +320,15 @@ export default class OffersController extends Controller { this._saveOfferProperty('amount', amount); } + @action + setTrialDuration(e) { + let amount = e.target.value; + if (amount !== '') { + amount = parseInt(amount); + } + this._saveOfferProperty('amount', amount); + } + @action setOfferName(e) { this._saveOfferProperty('name', e.target.value); @@ -418,6 +435,19 @@ export default class OffersController extends Controller { } } + @action + changeType(type) { + if (type === 'trial') { + this._saveOfferProperty('type', 'trial'); + this._saveOfferProperty('amount', 0); + this._saveOfferProperty('duration', 'trial'); + } else { + this._saveOfferProperty('type', 'percent'); + this._saveOfferProperty('amount', 0); + this._saveOfferProperty('duration', 'once'); + } + } + @action updateCadence(cadence, offerObj) { offerObj = offerObj || this.offer; diff --git a/ghost/admin/app/templates/offer.hbs b/ghost/admin/app/templates/offer.hbs index 79ad1ae940..d6019b6fd1 100644 --- a/ghost/admin/app/templates/offer.hbs +++ b/ghost/admin/app/templates/offer.hbs @@ -46,13 +46,18 @@