mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Wired expiring comp subscriptions on Admin
refs https://github.com/TryGhost/Team/issues/1727 - adds alpha feature flag for expiring comped subs - adds duration to complimentary subs to set expiry - shows details for expiring comped subs
This commit is contained in:
parent
fa26f6a783
commit
148fea8217
6 changed files with 88 additions and 3 deletions
|
@ -158,6 +158,9 @@
|
|||
{{else if sub.cancel_at_period_end}}
|
||||
<span class="gh-cp-membertier-renewal">Has access until {{sub.validUntil}}</span>
|
||||
<span class="gh-badge archived" data-test-text="member-subscription-status">Cancelled</span>
|
||||
{{else if sub.compExpiry}}
|
||||
<span class="gh-cp-membertier-renewal">Expires {{sub.compExpiry}}</span>
|
||||
<span class="gh-badge active" data-test-text="member-subscription-status">Active</span>
|
||||
{{else if sub.trialUntil}}
|
||||
<span class="gh-cp-membertier-renewal">Ends {{sub.trialUntil}}</span>
|
||||
<span class="gh-badge active" data-test-text="member-subscription-status">Active</span>
|
||||
|
|
|
@ -89,6 +89,11 @@ export default class extends Component {
|
|||
data.trialUntil = moment(sub.trial_end_at).format('D MMM YYYY');
|
||||
}
|
||||
}
|
||||
|
||||
if (!sub.id && this.feature.get('compExpiring') && sub.tier?.expiry_at) {
|
||||
data.compExpiry = moment(sub.tier.expiry_at).format('D MMM YYYY');
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
return tiers.map((tier) => {
|
||||
|
|
|
@ -41,6 +41,24 @@
|
|||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{#if (feature 'compExpiring')}}
|
||||
<GhFormGroup @errors={{this.errors}} @property="product-cadence">
|
||||
<label for="product-cadence" class="fw6 mt3">Select a duration</label>
|
||||
<span class="gh-select">
|
||||
<OneWaySelect
|
||||
@value={{this.expiryAt}}
|
||||
@options={{this.expiryOptions}}
|
||||
@optionValuePath="duration"
|
||||
@optionLabelPath="label"
|
||||
@optionTargetPath="duration"
|
||||
@disabled={{false}}
|
||||
@update={{this.updateExpiry}}
|
||||
/>
|
||||
{{svg-jar "arrow-down-small"}}
|
||||
</span>
|
||||
<GhErrorMessage @errors={{this.errors}} @property="product-cadence" />
|
||||
</GhFormGroup>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import ModalComponent from 'ghost-admin/components/modal-base';
|
||||
import moment from 'moment';
|
||||
import {action} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
|
@ -14,6 +15,30 @@ export default class ModalMemberTier extends ModalComponent {
|
|||
@tracked tiers = [];
|
||||
@tracked selectedTier = null;
|
||||
@tracked loadingTiers = false;
|
||||
@tracked expiryAt = 'forever';
|
||||
|
||||
@tracked expiryOptions = [
|
||||
{
|
||||
label: 'Forever',
|
||||
duration: 'forever'
|
||||
},
|
||||
{
|
||||
label: '1 Week',
|
||||
duration: 'week'
|
||||
},
|
||||
{
|
||||
label: '1 Month',
|
||||
duration: 'month'
|
||||
},
|
||||
{
|
||||
label: '6 Months',
|
||||
duration: 'half-year'
|
||||
},
|
||||
{
|
||||
label: '1 Year',
|
||||
duration: 'year'
|
||||
}
|
||||
];
|
||||
|
||||
@task({drop: true})
|
||||
*fetchTiers() {
|
||||
|
@ -67,6 +92,11 @@ export default class ModalMemberTier extends ModalComponent {
|
|||
this.closeModal();
|
||||
}
|
||||
|
||||
@action
|
||||
updateExpiry(expiryDuration) {
|
||||
this.expiryAt = expiryDuration;
|
||||
}
|
||||
|
||||
@task({drop: true})
|
||||
*addTier() {
|
||||
const url = `${this.ghostPaths.url.api(`members/${this.member.get('id')}`)}?include=tiers`;
|
||||
|
@ -82,14 +112,29 @@ export default class ModalMemberTier extends ModalComponent {
|
|||
});
|
||||
}
|
||||
|
||||
let expiryAt = null;
|
||||
|
||||
if (this.expiryAt === 'week') {
|
||||
expiryAt = moment.utc().add(7, 'days').startOf('day').toISOString();
|
||||
} else if (this.expiryAt === 'month') {
|
||||
expiryAt = moment.utc().add(1, 'month').startOf('day').toISOString();
|
||||
} else if (this.expiryAt === 'half-year') {
|
||||
expiryAt = moment.utc().add(6, 'months').startOf('day').toISOString();
|
||||
} else if (this.expiryAt === 'year') {
|
||||
expiryAt = moment.utc().add(1, 'year').startOf('day').toISOString();
|
||||
}
|
||||
const tiersData = {
|
||||
id: this.selectedTier
|
||||
};
|
||||
if (expiryAt) {
|
||||
tiersData.expiry_at = expiryAt;
|
||||
}
|
||||
const response = yield this.ajax.put(url, {
|
||||
data: {
|
||||
members: [{
|
||||
id: this.member.get('id'),
|
||||
email: this.member.get('email'),
|
||||
tiers: [{
|
||||
id: this.selectedTier
|
||||
}]
|
||||
tiers: [tiersData]
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -61,6 +61,7 @@ export default class FeatureService extends Service {
|
|||
@feature('beforeAfterCard') beforeAfterCard;
|
||||
@feature('newsletterPaywall') newsletterPaywall;
|
||||
@feature('freeTrial') freeTrial;
|
||||
@feature('compExpiring') compExpiring;
|
||||
@feature('memberAttribution') memberAttribution;
|
||||
@feature('searchHelper') searchHelper;
|
||||
|
||||
|
|
|
@ -239,6 +239,19 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Cardless trials</h4>
|
||||
<p class="gh-expandable-description">
|
||||
Add support for expiring complimentary subscriptions
|
||||
</p>
|
||||
</div>
|
||||
<div class="for-switch">
|
||||
<GhFeatureFlag @flag="compExpiring" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
|
|
Loading…
Add table
Reference in a new issue