context = window rest = context.JK.Rest() @RetailerTeacherLandingPage = React.createClass({ render: () -> if this.props.retailer.large_photo_url? logo = `
` loggedIn = context.JK.currentUserId? && !this.props.preview if this.state.done ctaButtonText = 'sending you in...' else if this.state.processing ctaButtonText = 'hold on...' else if loggedIn ctaButtonText = "ALREADY A JAMKAZAM USER" else ctaButtonText = "SIGN UP" if loggedIn register = `
` else if this.state.loginErrors? for key, value of this.state.loginErrors break errorText = context.JK.getFullFirstError(key, this.state.loginErrors, {email: 'Email', password: 'Password', 'terms_of_service': 'The terms of service'}) register = `
{errorText}

We will not share your email.
See our privacy policy.

` `
{logo}

REGISTER AS A TEACHER

with {this.props.retailer.name}


Please register here if you are currently a teacher with {this.props.retailer.name}, and if you plan to teach online music lessons for students of {this.props.retailer.name} using the JamKazam service. When you have registered, we will email you instructions to set up your online teacher profile, and we'll schedule a brief online training session to make sure you are comfortable using the service and ready to go with students in online lessons.

{register}
` getInitialState: () -> {loginErrors: null, processing: false} componentDidMount: () -> $root = $(this.getDOMNode()) $checkbox = $root.find('.terms-checkbox') context.JK.checkbox($checkbox) # add item to cart, create the user if necessary, and then place the order to get the free JamTrack. ctaClick: (e) -> e.preventDefault() return if @state.processing @setState({loginErrors: null}) loggedIn = context.JK.currentUserId? if loggedIn #window.location.href = "/client#/jamclass" window.location.href = "/client#/profile/#{context.JK.currentUserId}" else @createUser() @setState({processing:true}) createUser: () -> $form = $('.retailer-signup-form') email = $form.find('input[name="email"]').val() password = $form.find('input[name="password"]').val() terms = $form.find('input[name="terms"]').is(':checked') rest.signup({ email: email, password: password, first_name: null, last_name: null, terms: terms, teacher: true, retailer_invitation_code: this.props.invitation_code, retailer_id: this.props.retailer.id }) .done((response) => @setState({done: true}) #window.location.href = "/client#/jamclass" window.location.href = "/client#/profile/#{response.id}" ).fail((jqXHR) => @setState({processing: false}) if jqXHR.status == 422 response = JSON.parse(jqXHR.responseText) if response.errors @setState({loginErrors: response.errors}) else context.JK.app.notify({title: 'Unknown Signup Error', text: jqXHR.responseText}) else context.JK.app.notifyServerError(jqXHR, "Unable to Sign Up") ) })