Added trial info on member subscription

refs https://github.com/TryGhost/Team/issues/1724

- shows free trial info in member detail page for subscription
This commit is contained in:
Rishabh 2022-08-09 19:19:54 +05:30
parent 43d41e8b0e
commit 63fc06da28
2 changed files with 17 additions and 2 deletions

View File

@ -145,11 +145,19 @@
<div class="gh-membertier-subscription" data-test-subscription={{index}}>
<div>
<div>
<span class="gh-cp-membertier-pricelabel">{{sub.price.nickname}}</span>
{{#if sub.trialUntil}}
<span class="gh-cp-membertier-pricelabel">Free Trial</span>
{{else}}
<span class="gh-cp-membertier-pricelabel">{{sub.price.nickname}}</span>
{{/if}}
&ndash;
{{#if (eq sub.status "canceled")}}
<span class="gh-cp-membertier-renewal">Ended {{sub.validUntil}}</span>
<span class="gh-badge archived" data-test-text="member-subscription-status">Cancelled</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>
{{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>

View File

@ -71,7 +71,7 @@ export default class extends Component {
let subscriptionData = subscriptions.filter((sub) => {
return !!sub.price;
}).map((sub) => {
return {
const data = {
...sub,
startDate: sub.start_date ? moment(sub.start_date).format('D MMM YYYY') : '-',
validUntil: sub.current_period_end ? moment(sub.current_period_end).format('D MMM YYYY') : '-',
@ -83,6 +83,13 @@ export default class extends Component {
},
isComplimentary: !sub.id
};
if (this.feature.get('freeTrial') && sub.trial_end_at) {
const inTrialMode = moment(sub.trial_end_at).isAfter(new Date(), 'day');
if (inTrialMode) {
data.trialUntil = moment(sub.trial_end_at).format('D MMM YYYY');
}
}
return data;
});
return tiers.map((tier) => {
let tierSubscriptions = subscriptionData.filter((subscription) => {