From 63fc06da2802cd955d9bcffc43ffb464f14a4c1b Mon Sep 17 00:00:00 2001 From: Rishabh Date: Tue, 9 Aug 2022 19:19:54 +0530 Subject: [PATCH] Added trial info on member subscription refs https://github.com/TryGhost/Team/issues/1724 - shows free trial info in member detail page for subscription --- ghost/admin/app/components/gh-member-settings-form.hbs | 10 +++++++++- ghost/admin/app/components/gh-member-settings-form.js | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/gh-member-settings-form.hbs b/ghost/admin/app/components/gh-member-settings-form.hbs index 17f2b6742b..f16e5f9289 100644 --- a/ghost/admin/app/components/gh-member-settings-form.hbs +++ b/ghost/admin/app/components/gh-member-settings-form.hbs @@ -145,11 +145,19 @@
- {{sub.price.nickname}} + {{#if sub.trialUntil}} + Free Trial + {{else}} + {{sub.price.nickname}} + {{/if}} + – {{#if (eq sub.status "canceled")}} Ended {{sub.validUntil}} Cancelled + {{else if sub.trialUntil}} + Ends {{sub.trialUntil}} + Active {{else if sub.cancel_at_period_end}} Has access until {{sub.validUntil}} Cancelled diff --git a/ghost/admin/app/components/gh-member-settings-form.js b/ghost/admin/app/components/gh-member-settings-form.js index 4ffc670c24..266906d329 100644 --- a/ghost/admin/app/components/gh-member-settings-form.js +++ b/ghost/admin/app/components/gh-member-settings-form.js @@ -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) => {