Skip to content

Commit

Permalink
Free Trials: Handle the case where a trial will expire in less than a…
Browse files Browse the repository at this point in the history
… day
  • Loading branch information
drewblaisdell committed Dec 21, 2015
1 parent 688e81c commit 4625845
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/lib/plans/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export function getDaysUntilExpiry( plan ) {
};

export function isInGracePeriod( plan ) {
return getDaysUntilUserFacingExpiry( plan ) <= 0 && getDaysUntilExpiry( plan ) > 0;
return getDaysUntilUserFacingExpiry( plan ) <= 0;
};
9 changes: 6 additions & 3 deletions client/my-sites/plans/plan-overview/plan-status/progress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,25 @@ const PlanStatusProgress = React.createClass( {
// we strip the hour/minute/second/millisecond data here from `subscribed_date` to match `expiry`
trialPeriodInDays = getCurrentTrialPeriodInDays( plan ),
timeUntilExpiryInDays = isInGracePeriod( plan )
? getDaysUntilExpiry( plan )
? Math.max( getDaysUntilExpiry( plan ), 0 )
: getDaysUntilUserFacingExpiry( plan ),
progress = Math.max( 0.5, trialPeriodInDays - timeUntilExpiryInDays );

return (
<ProgressBar
value={ progress }
total={ trialPeriodInDays }
/>
total={ trialPeriodInDays } />
);
},

renderDaysRemaining() {
const { plan } = this.props;

if ( isInGracePeriod( plan ) ) {
if ( getDaysUntilExpiry( plan ) <= 0 ) {
return this.translate( 'Plan features will be removed momentarily' );
}

return this.translate(
'Plan features will be removed in %(daysUntilExpiry)s day',
'Plan features will be removed in %(daysUntilExpiry)s days',
Expand Down

0 comments on commit 4625845

Please sign in to comment.