context = window @SubscriptionConcern = React.createClass({ displayName: 'SubscriptionConcern' getTimeRemaining: (t) -> if t < 0 t = -t seconds = Math.floor( (t/1000) % 60 ); minutes = Math.floor( (t/1000/60) % 60 ); hours = Math.floor( (t/(1000*60*60)) % 24 ); days = Math.floor( t/(1000*60*60*24) ); return { 'total': t, 'days': days, 'hours': hours, 'minutes': minutes, 'seconds': seconds }; displayTime: () -> if false # offset time by 10 minutes to get the 'you need to wait message' in untilTime = @getTimeRemaining(@props.subscription.until.total + (10 * 60 * 1000)) else untilTime = @props.subscription.until timeString = '' if untilTime.days != 0 timeString += "#{untilTime.days} days, " if untilTime.hours != 0 || timeString.length > 0 timeString += "#{untilTime.hours} hours, " if untilTime.minutes != 0 || timeString.length > 0 timeString += "#{untilTime.minutes} minutes, " if untilTime.seconds != 0 || timeString.length > 0 timeString += "#{untilTime.seconds} seconds" if timeString == '' 'now!' timeString openBrowserToPayment: (e) -> context.JK.popExternalLink("/client#/account/subscription", true) e.preventDefault(); openBrowserToPlanComparison: (e) -> context.JK.popExternalLink("https://jamkazam.freshdesk.com/support/solutions/articles/66000122535-what-are-jamkazam-s-free-vs-premium-features-") e.preventDefault(); return 'noclose' render: () -> content = null if @props.subscription.participants > 1 if @props.subscription.until.total < 60000 content = `

You have run out of time.

Compare plans and consider upgrading your plan for more play time and premium features.

` else if @props.subscription.main_concern_type == 'remaining_session_play_time' content = `

You will run out play time for this session in:

{this.displayTime()}

Compare plans and consider upgrading your plan for more play time and premium features.

` else content = `

You will run out of monthly play time in:

{this.displayTime()}

Compare plans and consider upgrading your plan for more play time and premium features.

` if content? `
{content}
` else `
` })