context = window @InLessonBroadcast = React.createClass({ displayName: 'In Lesson Broadcast' 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 @props.lessonSession.initialWindow # offset time by 10 minutes to get the 'you need to wait message' in untilTime = @getTimeRemaining(@props.lessonSession.until.total + (10 * 60 * 1000)) else untilTime = @props.lessonSession.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 render: () -> if @props.lessonSession.isStudent role = 'student' otherRole = 'teacher' billingStatement = 'charged for the lesson' else role = 'teacher' otherRole = 'student' billingStatement = 'not receive payment for the lesson' if @props.lessonSession.completed if @props.lessonSession.success content = `

This lesson is over.

` else content = `

This lesson is over, but will not be billed.

` else if @props.lessonSession.beforeSession content = `

This lesson will start in:

{this.displayTime()}

` else if @props.lessonSession.initialWindow content = `

You need to wait in this session for

{this.displayTime()}

to allow time for your {otherRole} to join you. If you leave before this timer reaches zero, and your {otherRole} joins this session, you will be marked absent and {billingStatement}.

` else if @props.lessonSession.teacherFault if @props.lessonSession.isStudent content = `

You may now leave the session.

Your teacher will be marked absent and penalized for missing the lesson. You will not be charged for this lesson.

We apologize for your inconvenience, and we will work to remedy this situation.

` else content = `

You may now leave the session.

Your student will be marked absent and penalized for missing the lesson. You will still received payment for this lesson.

We apologize for your inconvenience, and we will work to remedy this situation.

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