<commit_before>import React, { Component } from 'react';
import Config from '../config';
import FlatButton from 'material-ui/lib/flat-button';
import RaisedButton from 'material-ui/lib/raised-button';
import axios from 'axios';
import Popover from 'material-ui/lib/popover/popover';
import PopoverAnimationFromTop from 'material-ui/lib/popover/popover-animation-from-top';

export default class NewUser extends Component {

    // this.axiosPost = this.axiosPost.bind(this) can use this instead of ev =>
    //
  // getInitialState() {
  //   return {showForm: false}
  // }
  // this from ES5 is the same as the constructor below.
  // constructor is a lot like def initialize from ruby

  constructor(props) {
    super(props)
  }

  axiosPost(event) {
    event.preventDefault();
    console.log(this.refs.firstName.value)
    axios.post('http://localhost:3000/users', {
      avatar: this.refs.avatar.value,
      first_name: this.refs.firstName.value,
      last_name: this.refs.lastName.value,
      email: this.refs.email.value,
      password: <PASSWORD>,
      password_confirmation: <PASSWORD>.value,
      authenticity_token: this.refs.authenticityToken.value
    })

      .then(function(response){
        // console.log(this.refs.firstName.value)
        console.log('success, response: ', response)
        });
  }

  render() {
    return (
      <div>
       <form onSubmit={ev => this.axiosPost(ev)} encType="multipart/form-data">

          <div>
            <label htmlFor="first_name">URL to your photo:</label>
            <input ref="avatar" type="text" name="user[avatar]" id="avatar" placeholder="URL to your photo" />
          </div>
          <div>
            <label htmlFor="first_name">First name:</label>
            <input ref="firstName" type="text" name="user[first_name]" id="first_name" placeholder="<NAME>" />
          </div>
          <div>
            <label htmlFor="last_name">Last name:</label>
            <input ref="lastName" type="text" name="user[last_name]" id="last_name" placeholder="Last name" />
          </div>
          <div>
            <label htmlFor="email">Email:</label>
            <input ref="email" type="text" name="user[email]" id="email" placeholder="Email" />
          </div>
          <div>
            <label htmlFor="password">Choose a password:</label>
            <input ref="password" type="password" name="user[password]" id="password" placeholder="Password" />
          </div>
          <div>
            <label htmlFor="password_confirmation">Confirm your password:</label>
            <input ref="passwordConfirmation" type="password" name="user[password_confirmation]" id="password_confirmation" placeholder="Confirm your password" />
          </div>
          <div>
        <input ref="authenticityToken" type="hidden" name="authenticity_token" value={this.props.authenticity_token} />
        </div>
          <div>
            <FlatButton
              onClick={this.props.handleClose}
              label="Submit"
              primary={true}
              type="submit" />
          </div>
        </form>
      </div>
    );
  }
}<commit_msg>material UI form set up for new users<commit_after>import React, { Component } from 'react';
import Config from '../config';
import FlatButton from 'material-ui/lib/flat-button';
import RaisedButton from 'material-ui/lib/raised-button';
import TextField from 'material-ui/lib/text-field';
import axios from 'axios';

export default class NewUser extends Component {

    // this.axiosPost = this.axiosPost.bind(this) can use this instead of ev =>
    //
  // getInitialState() {
  //   return {showForm: false}
  // }
  // this from ES5 is the same as the constructor below.
  // constructor is a lot like def initialize from ruby

  constructor(props) {
    super(props)
  }

  axiosPost = (event) => {
    event.preventDefault();
    console.log(this.refs.firstName.value)
    axios.post('http://localhost:3000/users', {
      avatar: this.refs.avatar.getValue(),
      first_name: this.refs.firstName.getValue(),
      last_name: this.refs.lastName.getValue(),
      email: this.refs.email.getValue(),
      password: this.refs.password.getValue(),
      password_confirmation: this.refs.passwordConfirmation.getValue()
      // authenticity_token: this.refs.authenticityToken.value
    })

      .then(function(response){
        // console.log(this.refs.firstName.value)
        console.log('success, response: ', response)
        });
  }

  render() {
    return (
      <div>
       <form onSubmit={this.axiosPost}>
       <TextField
        id="avatar-field"
        hintText="A photo"
        floatingLabelText="Avatar"
        ref="avatar"
        />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <TextField
        id="first-name-field"
        hintText="E.g. Donald"
        floatingLabelText="First name"
        ref="firstName"
        />
        <TextField
          id="last-name-field"
          hintText="E.g. Duck"
          floatingLabelText="Last name"
          ref="lastName"
        />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <TextField
          id="email-field"
          hintText="E.g. <EMAIL>"
          floatingLabelText="Email"
          ref="email"
        />
        <TextField
          id="password-field"
          hintText="Pick something secure"
          type="password"
          floatingLabelText="Password"
          ref="password"
        />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <TextField
          id="password-confirmation-field"
          hintText="Pick something secure"
          type="password"
          floatingLabelText="Confirm your password"
          ref="passwordConfirmation"
        /><br />
        <FlatButton
          onClick={this.props.handleClose}
          label="Submit"
          type="submit"
          primary={true}
        />
        </form>
      </div>

    );
  }
}

{'fraction_non_alphanumeric': 0.13864256480218282, 'fraction_numerical': 0.0017053206002728514, 'mean_word_length': 2.3980301274623406, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 63, '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': '2196058', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1682, 'n_words': 344}