jam-cloud/web/app/assets/javascripts/react-components/RescheduleLessonDialog.js.j...

82 lines
2.2 KiB
CoffeeScript
Raw Permalink Normal View History

context = window
@RescheduleLessonDialog = React.createClass({
mixins: [@PostProcessorMixin, Reflux.listenTo(@AppStore, "onAppInit")]
teacher: false
beforeShow: (args) ->
logger.debug("RescheduleLessonDialog.beforeShow", args.d1)
@setState({id: args.d1, lesson_session: null})
rest.getLesson({id: args.d1}).done((response) => @getLessonDone(response)).fail((jqXHR) => @getLessonFail(jqXHR))
getLessonDone: (lesson_session) ->
@postProcessLesson(lesson_session)
@setState({lesson_session: lesson_session})
getLessonFail: (jqXHR) ->
@app.ajaxError(jqXHR)
afterHide: () ->
onAppInit: (@app) ->
dialogBindings = {
'beforeShow': @beforeShow,
'afterHide': @afterHide
};
@app.bindDialog('reschedule-lesson-dialog', dialogBindings);
componentDidMount: () ->
@root = $(@getDOMNode())
getInitialState: () ->
{id: null, lesson_session: null}
onCloseClicked: (e) ->
e.preventDefault()
@app.layout.closeDialog('reschedule-lesson-dialog');
lesson: () ->
this.state.lesson_session
viewerStudent: () ->
@lesson().student.id == context.JK.currentUserId
viewerTeacher: () ->
!@viewerStudent()
render: () ->
title = 'loading...'
if this.state.lesson_session?
title = "reschedule lesson"
lessonSessionId = this.state.lesson_session.id
other = this.state.lesson_session.other
if @viewerStudent() && @sessionStartingSoon()
title = 'Policy Issue'
content =
`<div>
<p>Were sorry, but you cannot reschedule a lesson less than 24 hours before the lesson start time. This is not allowed in the <a href="/corp/terms" target="_blank">terms of service</a> because the instructor cannot reasonably be expected to be able to backfill the time slot that has been lost.</p>
<div className="actions">
<a href="button-orange" onClick={this.onCloseClicked}>CLOSE</a>
</div>
</div>`
`<div className="RescheduleLessonTop">
<div className="content-head">
<img className="content-icon" src="/assets/content/icon_add.png" height={19} width={19}/>
<h1>{title}</h1>
</div>
<div className="dialog-inner">
</div>
</div>`
})