<commit_before>EC.JoinClassStage1 = React.createClass({

  addClass: function() {
    $.post('../students_classrooms', {classcode: this.refs.classCodeInput.value})
      .done(function(data){
        // ensure that it was successful here
      });
  },


  render: function() {
    return (
      <div className='additional-class stage-1 text-center'>
        <h1>Join a New Class</h1>
        <span>Add Your Class Code</span>
        <br/>
        <input ref='classCodeInput' placeholder='e.g. fresh-bread'></input>
        <br/>
        <button className='button-green' onClick={this.addClass}>Join Your Class</button>
        <br/>
        <span>Don't know your classcode?<br/>
          You can ask your teacher for it.</span>
      </div>
    );
  }

});
<commit_msg>gives success or error messages<commit_after>EC.JoinClassStage1 = React.createClass({

  getInitialState: function() {
    return {error: null}
  },

  addClass: function() {
    var that = this
    $.post('../students_classrooms', {classcode: this.refs.classCodeInput.value})
      .done(function(){
        alert('added');
      })
      .fail(function() {
        that.setState({error: 'Invalid Classcode'})
      })
  },

  errorMessage: function() {
    if (this.state.error !== null) {
      return <div><span className='error-message'>Invalid Classcode</span></div>;
    }
  },


  render: function() {
    return (
      <div className='additional-class stage-1 text-center'>
        <h1>Join a New Class</h1>
        <span>Add Your Class Code</span>
        <br/>
        <input ref='classCodeInput' placeholder='e.g. fresh-bread'></input>
        <br/>
        {this.errorMessage()}
        <button className='button-green' onClick={this.addClass}>Join Your Class</button>
        <br/>
        <span>Don't know your classcode?<br/>
          You can ask your teacher for it.</span>
      </div>
    );
  }

});

{'fraction_non_alphanumeric': 0.1583949313621964, 'fraction_numerical': 0.004223864836325237, 'mean_word_length': 2.477064220183486, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5220533', 'n_tokens_mistral': 588, 'n_tokens_neox': 573, 'n_words': 127}