<commit_before>React = require 'react'
BS = require 'react-bootstrap'
ENTER = 'Enter'

{CourseListing} = require './listing'
ErrorList = require './error-list'
Course = require './model'

InviteCodeInput = React.createClass

  propTypes:
    title: React.PropTypes.string.isRequired
    course: React.PropTypes.instanceOf(Course)
    currentCourses: React.PropTypes.arrayOf(React.PropTypes.instanceOf(Course))

  startRegistration: ->
    @props.course.register(@refs.input.getValue())

  onKeyPress: (ev) ->
    @startRegistration() if ev.key is ENTER

  renderCurrentCourses: ->
    <div className='text-center'>
      <h3>You are not registered for this course.</h3>
      <p>Did you mean to go to one of these?</p>
      <CourseListing
        courses={@props.currentCourses}
        cnxUrl={@props.cnxUrl}/>
    </div>

  render: ->
    button =
      <button className="btn btn-default" type="button" autoFocus
        onKeyPress={@onKeyPress}
        onClick={@startRegistration}>Register</button>

    <div className="form-group">
      {@renderCurrentCourses() if @props.currentCourses?.length}
      <h3 className="text-center">{@props.title}</h3>
      <hr/>
      <ErrorList course={@props.course} />
      <div className="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-12">
        <BS.Input type="text" ref="input" label="Course invitation code"
          placeholder="Enter code" autoFocus
          onKeyPress={@onKeyPress}
          buttonAfter={button} />
      </div>
    </div>

module.exports = InviteCodeInput<commit_msg>Correct input label to be "enrollment code"<commit_after>React = require 'react'
BS = require 'react-bootstrap'
ENTER = 'Enter'

{CourseListing} = require './listing'
ErrorList = require './error-list'
Course = require './model'

InviteCodeInput = React.createClass

  propTypes:
    title: React.PropTypes.string.isRequired
    course: React.PropTypes.instanceOf(Course)
    currentCourses: React.PropTypes.arrayOf(React.PropTypes.instanceOf(Course))

  startRegistration: ->
    @props.course.register(@refs.input.getValue())

  onKeyPress: (ev) ->
    @startRegistration() if ev.key is ENTER

  renderCurrentCourses: ->
    <div className='text-center'>
      <h3>You are not registered for this course.</h3>
      <p>Did you mean to go to one of these?</p>
      <CourseListing
        courses={@props.currentCourses}
        cnxUrl={@props.cnxUrl}/>
    </div>

  render: ->
    button =
      <button className="btn btn-default" type="button" autoFocus
        onKeyPress={@onKeyPress}
        onClick={@startRegistration}>Register</button>

    <div className="form-group">
      {@renderCurrentCourses() if @props.currentCourses?.length}
      <h3 className="text-center">{@props.title}</h3>
      <hr/>
      <ErrorList course={@props.course} />
      <div className="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-12">
        <BS.Input type="text" ref="input" label="Enter the two-word enrollment code"
          placeholder="enrollment code" autoFocus
          onKeyPress={@onKeyPress}
          buttonAfter={button} />
      </div>
    </div>

module.exports = InviteCodeInput
{'fraction_non_alphanumeric': 0.14176974310180782, 'fraction_numerical': 0.006343165239454488, 'mean_word_length': 3.2737127371273713, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 47, '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': '4803239', 'n_tokens_mistral': 1000, 'n_tokens_neox': 980, 'n_words': 203}