2016-05-07 18:45:02 +00:00
|
|
|
context = window
|
|
|
|
|
|
|
|
|
|
@InLessonBroadcast = React.createClass({
|
|
|
|
|
displayName: 'In Lesson Broadcast'
|
|
|
|
|
|
2016-05-09 21:47:55 +00:00
|
|
|
getTimeRemaining: (t) ->
|
2016-05-07 18:45:02 +00:00
|
|
|
|
2016-05-09 21:47:55 +00:00
|
|
|
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
|
2016-05-07 18:45:02 +00:00
|
|
|
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
|
2016-05-09 21:47:55 +00:00
|
|
|
timeString += "#{untilTime.minutes} minutes, "
|
2016-05-07 18:45:02 +00:00
|
|
|
if untilTime.seconds != 0 || timeString.length > 0
|
|
|
|
|
timeString += "#{untilTime.seconds} seconds"
|
|
|
|
|
|
|
|
|
|
if timeString == ''
|
|
|
|
|
'now!'
|
|
|
|
|
timeString
|
|
|
|
|
|
|
|
|
|
render: () ->
|
2016-05-26 23:10:05 +00:00
|
|
|
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'
|
2016-05-07 18:45:02 +00:00
|
|
|
if @props.lessonSession.completed
|
|
|
|
|
if @props.lessonSession.success
|
|
|
|
|
content = `<div className="message">
|
|
|
|
|
<p>This lesson is over.</p>
|
|
|
|
|
</div>`
|
|
|
|
|
else
|
|
|
|
|
content = `<div className="message">
|
|
|
|
|
<p>This lesson is over, but will not be billed.</p>
|
|
|
|
|
</div>`
|
|
|
|
|
else if @props.lessonSession.beforeSession
|
|
|
|
|
content = `<div className="message">
|
|
|
|
|
<p>This lesson will start in:</p>
|
|
|
|
|
<p className="time">{this.displayTime()}</p>
|
|
|
|
|
</div>`
|
|
|
|
|
else if @props.lessonSession.initialWindow
|
|
|
|
|
content = `<div className="message">
|
|
|
|
|
<p>You need to wait in this session for</p>
|
2016-05-09 21:47:55 +00:00
|
|
|
<p className="time">{this.displayTime()}</p>
|
2016-05-26 23:10:05 +00:00
|
|
|
<p>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}.</p>
|
2016-05-07 18:45:02 +00:00
|
|
|
</div>`
|
|
|
|
|
else if @props.lessonSession.teacherFault
|
2016-05-26 23:10:05 +00:00
|
|
|
if @props.lessonSession.isStudent
|
2016-05-07 18:45:02 +00:00
|
|
|
content = `<div className="message">
|
2016-05-26 23:10:05 +00:00
|
|
|
<p>You may now leave the session.</p>
|
|
|
|
|
<p>Your teacher will be marked absent and penalized for missing the lesson. You will not be charged for this lesson.</p>
|
|
|
|
|
<p>We apologize for your inconvenience, and we will work to remedy this situation.</p>
|
2016-05-07 18:45:02 +00:00
|
|
|
</div>`
|
|
|
|
|
else
|
|
|
|
|
content = `<div className="message">
|
|
|
|
|
<p>You may now leave the session.</p>
|
2016-05-26 23:10:05 +00:00
|
|
|
<p>Your student will be marked absent and penalized for missing the lesson. You will still received payment for this lesson.</p>
|
2016-05-07 18:45:02 +00:00
|
|
|
<p>We apologize for your inconvenience, and we will work to remedy this situation.</p>
|
|
|
|
|
</div>`
|
|
|
|
|
|
2016-05-10 17:59:01 +00:00
|
|
|
if content?
|
|
|
|
|
`<div className="broadcast-notification lesson">
|
|
|
|
|
{content}
|
|
|
|
|
</div>`
|
|
|
|
|
else
|
|
|
|
|
null
|
2016-05-07 18:45:02 +00:00
|
|
|
|
|
|
|
|
})
|