context = window rest = context.JK.Rest() logger = context.JK.logger AppStore = context.AppStore SchoolActions = context.SchoolActions SchoolStore = context.SchoolStore UserStore = context.UserStore profileUtils = context.JK.ProfileUtils @AccountSchoolScreen = React.createClass({ mixins: [ ICheckMixin, Reflux.listenTo(AppStore, "onAppInit"), Reflux.listenTo(SchoolStore, "onSchoolChanged") Reflux.listenTo(UserStore, "onUserChanged") ] shownOnce: false screenVisible: false TILE_ACCOUNT: 'account' TILE_MEMBERS: 'members' TILE_EARNINGS: 'earnings' TILE_AGREEMENT: 'agreement' TILES: ['account', 'members', 'earnings', 'agreement'] onAppInit: (@app) -> @app.bindScreen('account/school', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide}) onSchoolChanged: (schoolState) -> @setState(schoolState) onUserChanged: (userState) -> @noSchoolCheck(userState?.user) @setState({user: userState?.user}) componentDidMount: () -> @checkboxes = [{selector: 'input.slot-decision', stateKey: 'slot-decision'}] @root = $(@getDOMNode()) @iCheckify() componentDidUpdate: () -> @iCheckify() checkboxChanged: (e) -> checked = $(e.target).is(':checked') value = $(e.target).val() @setState({userSchedulingComm: value}) beforeHide: (e) -> #ProfileActions.viewTeacherProfileDone() @screenVisible = false return true beforeShow: (e) -> noSchoolCheck: (user) -> if user?.id? && @screenVisible if !user.owned_school_id? window.JK.Banner.showAlert("You are not the owner of a school in our systems. If you are, please contact support@jamkazam.com and we'll update your account.") return false else if !@shownOnce @shownOnce = true SchoolActions.refresh(user.owned_school_id) return true else return false afterShow: (e) -> @screenVisible = true logger.debug("AccountSchoolScreen: afterShow") logger.debug("after show", @state.user) @noSchoolCheck(@state.user) getInitialState: () -> { school: null, user: null, selected: 'account', userSchedulingComm: null, updateErrors: null, schoolName: null, studentInvitations: null, teacherInvitations: null, updating: false, distributions: [] } isSchoolManaged: () -> if this.state.userSchedulingComm? this.state.userSchedulingComm == 'school' else this.state.school.scheduling_communication == 'school' nameValue: () -> if this.state.schoolName? this.state.schoolName else this.state.school.name nameChanged: (e) -> $target = $(e.target) val = $target.val() @setState({schoolName: val}) onCancel: (e) -> e.preventDefault() context.location.href = '/client#/account' onUpdate: (e) -> e.preventDefault() if this.state.updating return name = @root.find('input[name="name"]').val() if @isSchoolManaged() scheduling_communication = 'school' else scheduling_communication = 'teacher' correspondence_email = @root.find('input[name="correspondence_email"]').val() @setState(updating: true) rest.updateSchool({ id: this.state.school.id, name: name, scheduling_communication: scheduling_communication, correspondence_email: correspondence_email }).done((response) => @onUpdateDone(response)).fail((jqXHR) => @onUpdateFail(jqXHR)) onUpdateDone: (response) -> @setState({school: response, userSchedulingComm: null, schoolName: null, updateErrors: null, updating: false}) @app.layout.notify({title: "update success", text: "Your school information has been successfully updated"}) onUpdateFail: (jqXHR) -> handled = false @setState({updating: false}) if jqXHR.status == 422 errors = JSON.parse(jqXHR.responseText) handled = true @setState({updateErrors: errors}) if !handled @app.ajaxError(jqXHR, null, null) inviteTeacher: () -> @app.layout.showDialog('invite-school-user', {d1: true}) inviteStudent: () -> @app.layout.showDialog('invite-school-user', {d1: false}) resendInvitation: (id, e) -> e.preventDefault() rest.resendSchoolInvitation({ id: this.state.school.id, invitation_id: id }).done((response) => @resendInvitationDone(response)).fail((jqXHR) => @resendInvitationFail(jqXHR)) resendInvitationDone: (response) -> @app.layout.notify({title: 'invitation resent', text: 'Invitation was resent to ' + response.email}) resendInvitationFail: (jqXHR) -> @app.ajaxError(jqXHR) deleteInvitation: (id, e) -> e.preventDefault() rest.deleteSchoolInvitation({ id: this.state.school.id, invitation_id: id }).done((response) => @deleteInvitationDone(id, response)).fail((jqXHR) => @deleteInvitationFail(jqXHR)) deleteInvitationDone: (id, response) -> context.SchoolActions.deleteInvitation(id) deleteInvitationFail: (jqXHR) -> @app.ajaxError(jqXHR) removeFromSchool: (id, isTeacher, e) -> if isTeacher rest.deleteSchoolTeacher({ id: this.state.school.id, teacher_id: id }).done((response) => @removeFromSchoolDone(response)).fail((jqXHR) => @removeFromSchoolFail(jqXHR)) else rest.deleteSchoolStudent({ id: this.state.school.id, student_id: id }).done((response) => @removeFromSchoolDone(response)).fail((jqXHR) => @removeFromSchoolFail(jqXHR)) removeFromSchoolDone: (school) -> context.JK.Banner.showNotice("User removed", "User was removed from your school.") context.SchoolActions.updateSchool(school) removeFromSchoolFail: (jqXHR) -> @app.ajaxError(jqXHR) renderUser: (user, isTeacher) -> photo_url = user.photo_url if !photo_url? photo_url = '/assets/shared/avatar_generic.png' mailto = "mailto:#{user.email}" `
` renderInvitation: (invitation) -> `| {invitation.first_name} {invitation.last_name} |
No teachers
` teachers renderStudents: () -> students = [] if this.state.school.students? && this.state.school.students.length > 0 for student in this.state.school.students students.push(@renderUser(student, false)) else students = `No students
` students renderTeacherInvitations: () -> invitations = [] if this.state.teacherInvitations? && this.state.teacherInvitations.length > 0 for invitation in this.state.teacherInvitations invitations.push(@renderInvitation(invitation)) else invitations = `No pending invitations
` invitations renderStudentInvitations: () -> invitations = [] if this.state.studentInvitations? && this.state.studentInvitations.length > 0 for invitation in this.state.studentInvitations invitations.push(@renderInvitation(invitation)) else invitations = `No pending invitations
` invitations mainContent: () -> if !@state.user? || !@state.school? `Coming soon
The agreement between your music school and JamKazam is part of JamKazam's terms of service. You can find the complete terms of service here. And you can find the section that is most specific to the music school terms here.