context = window rest = context.JK.Rest() logger = context.JK.logger AppStore = context.AppStore LocationActions = context.LocationActions RetailerActions = context.RetailerActions RetailerStore = context.RetailerStore UserStore = context.UserStore profileUtils = context.JK.ProfileUtils @AccountRetailerScreen = React.createClass({ mixins: [ ICheckMixin, Reflux.listenTo(AppStore, "onAppInit"), Reflux.listenTo(RetailerStore, "onRetailerChanged") Reflux.listenTo(UserStore, "onUserChanged") ] shownOnce: false screenVisible: false TILE_ACCOUNT: 'account' TILE_TEACHERS: 'teachers' TILE_SALES: 'sales' TILE_AGREEMENT: 'agreement' TILES: ['account', 'teachers', 'sales', 'agreement'] onAppInit: (@app) -> @app.bindScreen('account/retailer', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide}) onRetailerChanged: (retailerState) -> @setState(retailerState) onUserChanged: (userState) -> @noRetailerCheck(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) -> LocationActions.load() noRetailerCheck: (user) -> if user?.id? && @screenVisible if !user.owned_retailer_id? window.JK.Banner.showAlert("You are not the owner of a retailer in our systems. If you are, please contact support@jamkazam.com and we'll update your account.") return false else if !@shownOnce @shownOnce = true RetailerActions.refresh(user.owned_retailer_id) return true else return false afterShow: (e) -> @screenVisible = true logger.debug("AccountRetailerScreen: afterShow") logger.debug("after show", @state.user) @noRetailerCheck(@state.user) getInitialState: () -> { retailer: null, user: null, selected: 'account', updateErrors: null, retailerName: null, teacherSplit: null, teacherInvitations: null, updating: false } nameValue: () -> if this.state.retailerName? this.state.retailerName else this.state.retailer.name nameChanged: (e) -> $target = $(e.target) val = $target.val() @setState({retailerName: 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() region = @root.find('select[name="regions"]').val() city = @root.find('select[name="cities"]').val() password = @root.find('input[type="password"]').val() teacherSplit = @teacherSplit() if teacherSplit retailerSplit = Number((100 - teacherSplit).toFixed(2)) @setState(updating: true) rest.updateRetailer({ id: this.state.retailer.id, name: name, state: region, city: city, password:password, split: {teacher: teacherSplit, retailer: retailerSplit} }).done((response) => @onUpdateDone(response)).fail((jqXHR) => @onUpdateFail(jqXHR)) onUpdateDone: (response) -> @setState({retailer: response, retailerName: null, teacherSplit: null, updateErrors: null, updating: false}) @app.layout.notify({title: "update success", text: "Your retailer 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-retailer-user', {d1: true}) resendInvitation: (id, e) -> e.preventDefault() rest.resendRetailerInvitation({ id: this.state.retailer.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.deleteRetailerInvitation({ id: this.state.retailer.id, invitation_id: id }).done((response) => @deleteInvitationDone(id, response)).fail((jqXHR) => @deleteInvitationFail(jqXHR)) deleteInvitationDone: (id, response) -> context.RetailerActions.deleteInvitation(id) deleteInvitationFail: (jqXHR) -> @app.ajaxError(jqXHR) removeFromRetailer: (id, isTeacher, e) -> if isTeacher rest.deleteRetailerTeacher({id: this.state.retailer.id, teacher_id: id}).done((response) => @removeFromRetailerDone(response)).fail((jqXHR) => @removeFromRetailerFail(jqXHR)) removeFromRetailerDone: (retailer) -> context.JK.Banner.showNotice("User removed", "User was removed from your retailer.") context.RetailerActions.updateRetailer(retailer) removeFromRetailerFail: (jqXHR) -> @app.ajaxError(jqXHR) renderUser: (user, isTeacher) -> photo_url = user.photo_url if !photo_url? photo_url = '/assets/shared/avatar_generic.png' `
` renderInvitation: (invitation) -> `| {invitation.first_name} {invitation.last_name} |
No teachers
` teachers 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 mainContent: () -> if !@state.user? || !@state.retailer? `Coming soon
The agreement between your retailer 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 retailer terms here.