<commit_before>'use strict'

var React = require('react')
var request = require('xhr')
var { PersonalFields, AddressFields, MembershipFields} =
    require('../components/member_fields/specific.js')
var Navigation = require('../../shared/navigation.js')
var Spinner = require('../../shared/spinner.js')

var member_schema = require('../../models/members.js')
var manage_member = require('../hocs/manage_member.js')
var map = require('app/map.js')
var { standardise } = require('app/transform_dated')

var NewMember = React.createClass({
  displayName: 'AddMember',
  getInitialState: function () { return {} },

  submit_handler (e) {
    e.preventDefault()
    if (this.props.errors.length) { return }
    this.setState({ submitting: true })

    request({
      method: 'POST',
      uri: '/addmember',
      json: standardise(this.props.member),
    }, (err, res, body) => {
      this.setState({ submitting: false, submitted: true, member_id: body.id })
    })
  },

  blur_handler: function (e) {
    this.props.verify_member(
      e
      , () => {
        if (!this.props.member.date_joined) {
          this.props.validation_error('date_joined')
        }
      }
    )
  },

  render: function () {
    return (
  <div>
  <div className='new-member-container'>
    <h1>New Member Form</h1>
      <form onSubmit={this.submit_handler}>
        { [PersonalFields, AddressFields, MembershipFields].map((Fields, i) =>
          <Fields
              key={i}
              mode='edit'
              member={this.props.member}
              blur_handler={this.blur_handler}
              skips={['activation_status']}
              errors={this.props.errors}
              onChange={this.props.change_handler} /> ) }
        <input type='submit' value='Submit 'id='save-button' />
        { this.state.submitting ? <Spinner /> : '' }
        { this.state.submitted  ?
            <div id='member-num'>
              Member ID is: { this.state.member_id }
            </div> :
            '' }
      </form>
      <a href='#/' className='flex-button'>
        <button className='button-primary'>Home</button><commit_msg>better date joined handling<commit_after>'use strict'

var React = require('react')
var request = require('xhr')
var { PersonalFields, AddressFields, MembershipFields} =
    require('../components/member_fields/specific.js')
var Navigation = require('../../shared/navigation.js')
var Spinner = require('../../shared/spinner.js')

var member_schema = require('../../models/members.js')
var manage_member = require('../hocs/manage_member.js')
var map = require('app/map.js')
var { standardise } = require('app/transform_dated')

var NewMember = React.createClass({
  displayName: 'AddMember',
  getInitialState: function () { return {} },

  submit_handler (e) {
    e.preventDefault()
    // not checked server side
    if (!this.props.member.date_joined_error) {
      return this.setState({ date_joined_error: true })
    }
    this.setState({ submitting: true })

    request({
      method: 'POST',
      uri: '/addmember',
      json: standardise(this.props.member),
    }, (err, res, body) => {
      this.setState({ submitting: false, submitted: true, member_id: body.id })
    })
  },

  blur_handler: function (e) {
    this.props.verify_member(
      e
      , () => {
        if (!this.props.member.date_joined) {
          this.props.validation_error('date_joined')
        } else {
          this.setState({ date_joined_error: false })
        }
      }
    )
  },

  render: function () {
    return (
  <div>
  <div className='new-member-container'>
    <h1>New Member Form</h1>
      <form onSubmit={this.submit_handler}>
        { [PersonalFields, AddressFields, MembershipFields].map((Fields, i) =>
          <Fields
              key={i}
              mode='edit'
              member={this.props.member}
              blur_handler={this.blur_handler}
              skips={['activation_status']}
              errors={this.props.errors}
              onChange={this.props.change_handler} /> ) }
        <input type='submit' value='Submit 'id='save-button' />
        { this.state.submitting
          ? <Spinner />
        : this.state.date_joined_error
          ? <div id="spinner">Check 'Date Joined'</div>
        : this.state.submitted
            ? <div id='member-num'>
              Member ID is: { this.state.member_id }
            </div>
            : '' }
      </form>
      <a href='#/' className='flex-button'>
        <button className='button-primary'>Home</button>
{'fraction_non_alphanumeric': 0.15811587793011941, 'fraction_numerical': 0.0008845643520566122, 'mean_word_length': 2.43693009118541, 'pattern_counts': {'":': 0, '<': 33, '<?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': '2736311', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1347, 'n_words': 250}