<commit_before>import React, {Component} from 'react'

/**
 * States of login display
 */
const {
  LOGIN_FORM_TYPE_LOGIN,
  LOGIN_FORM_TYPE_REGISTER,
  LOGIN_FORM_TYPE_FORGOTPASSWORD,
  LOGIN_FORM_TYPE_RESET_PASSWD,
} = require('../../../../lib/constants').default

const I18n = require('./Translate').default

const {timeout, signUpWithPassword, dismissPopModel} = require('../../../../actions').default

class UserEmailSignUp extends Component {

  constructor(props) {
    super(props)
    this.state = this.initialState = {
      formState: 'COMMON',
      // Message
      errorMessage: null
    }
  }

  componentWillReceiveProps(nextProps, nextContext) {

  }

  async onButtonPress() {
    const {dispatch} = this.props

    let username = this.props.auth.form.fields.username
    let email = this.props.auth.form.fields.email
    let password = <PASSWORD>.props.auth.<PASSWORD>.fields.password

    this.setState({errorMessage: null})
    var errorMessage = null

    this.props.actions.signupRequest()

    try {
      await Promise.race([
        dispatch(signUpWithPassword(username, email, password)),
        timeout(15000)
      ])
    } catch (e) {
      this.props.actions.signupFailure(e)
      const message = e.message || e
      if (message !== 'Timed out' && message !== 'Canceled by user') {
        errorMessage = message
        // alert(message);
        // console.warn(e);
      }
    } finally {
      if (!!errorMessage) {
        this.setState({errorMessage: errorMessage})
      } else {
        this.props.dispatch(dismissPopModel())
        this.props.actions.signupSuccess()
      }
    }
  }

  render() {
    return (
      <div className="login" data-component-bound="true">
        <div className="signup-form-container">

          <div className="header">
            <h2>Sign Up for Yelp</h2>
            <p className="subheading">Connect with great local businesses</p>
          </div>

          <p className="fb-start" data-component-bound="true">
            <button
              onClick={(e) => {
                this.props.loginViaSocial('facebook')
              }}
              type="submit" value="submit" className="ybtn ybtn--social ybtn--facebook ybtn-full">
              <span>
                <div className="u-text-centered">
              <span id="login_facebook_icon"
                    aria-hidden="true"
                    className="icon icon--24-facebook icon--size-24 icon--currentColor">
                <svg className="icon_svg">
                  {/*<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#24x24_facebook"></use>*/}
                </svg>
              </span> Sign Up with Facebook</div>
              </span>
            </button>
          </p>

          <p className="legal-copy">Don't worry, we never post without your permission.</p>

          <fieldset className="hr-line">
            <legend align="center">OR</legend>
          </fieldset>

          {this.renderForm()}

        </div>
        <div className="sub-text-box">
          <small className="subtle-text">{'Already on Yelp? '}
            <a onClick={(e) => {
              this.props.toggleEvent(e, LOGIN_FORM_TYPE_LOGIN)
            }}
               className="signup-link" href="/signup">{'Log in'}</a>
          </small>
        </div>
      </div>
    )
  }

  renderForm() {
    return (
      <form className="yform signup-form  city-hidden" id="signup-form" method="POST" data-component-bound="true"
            _lpchecked="1">
        <input type="hidden" name="csrftok" className="csrftok"
               value="c8e6c7c922ac7654aae354e91cd235b9f49aa746b1477d58242544ae585f7a8c"/>
        <div className="js-password-meter-container" data-component-bound="true">
          <ul className="inline-layout clearfix">
            <li>
              <label className="placeholder-sub">First Name</label>
              <input id="first_name"
                     name="first_name"
                     placeholder="<NAME>"
                     required="required" type="text" value=""
                     className="login_input_email"
                     autocomplete="off"/>
            </li>

            <li>
              <label className="placeholder-sub">Last Name</label>
              <input id="last_name" name="last_name" placeholder="<NAME>" required="required" type="text" value=""/>
            </li>

          </ul>
          <label className="placeholder-sub">Email</label>
          <input id="email" name="email" placeholder="Email" required="required" type="email" value=""/>

          <label className="placeholder-sub">Password</label>
          <input id="password" name="password" placeholder="Password" required="required" type="password" value=""
                 className="login_input_password"
                 autocomplete="off"/>

          <input id="signup_source" name="signup_source" type="hidden" value="default"/>
        </div>

        <div className="captcha" id="signup-captcha"/>

        <p className="legal-copy legal-left">
          {'By signing up, you agree to Yelp’s '}<a className="legal-link" href="https://www.yelp.com.sg/static?p=tos">
          {'Terms of Service'}</a> and <a className="legal-link" href="/tos/privacy_en_ie_20160131">Privacy Policy</a>.
        </p>
        <button id="signup-button" type="submit" value="Sign Up"
                className="ybtn ybtn--primary disable-on-submit submit signup-button">
          <span>Sign Up</span>
        </button>
      </form>
    )
  }<commit_msg>Sign up.<commit_after>import React, {Component} from 'react'

/**
 * States of login display
 */
const {
  LOGIN_FORM_TYPE_LOGIN,
  LOGIN_FORM_TYPE_REGISTER,
  LOGIN_FORM_TYPE_FORGOTPASSWORD,
  LOGIN_FORM_TYPE_RESET_PASSWD,
} = require('../../../../lib/constants').default

const I18n = require('./Translate').default

const {timeout, signUpWithPassword, dismissPopModel} = require('../../../../actions').default

class UserEmailSignUp extends Component {

  constructor(props) {
    super(props)
    this.state = this.initialState = {
      formState: 'COMMON',
      // Message
      errorMessage: null
    }
  }

  componentWillReceiveProps(nextProps, nextContext) {

  }

  async onButtonPress() {
    const {dispatch} = this.props

    let username = this.props.auth.form.fields.username
    let email = this.props.auth.form.fields.email
    let password = this.props.auth.form.fields.password

    this.setState({errorMessage: null})
    var errorMessage = null

    this.props.actions.signupRequest()

    try {
      await Promise.race([
        dispatch(signUpWithPassword(username, email, password)),
        timeout(15000)
      ])
    } catch (e) {
      this.props.actions.signupFailure(e)
      const message = e.message || e
      if (message !== 'Timed out' && message !== 'Canceled by user') {
        errorMessage = message
        // alert(message);
        // console.warn(e);
      }
    } finally {
      if (!!errorMessage) {
        this.setState({errorMessage: errorMessage})
      } else {
        this.props.dispatch(dismissPopModel())
        this.props.actions.signupSuccess()
      }
    }
  }

  render() {
    return (
      <div className="login" data-component-bound="true">
        <div className="signup-form-container">

          <div className="header">
            <h2>Sign Up for Yelp</h2>
            <p className="subheading">Connect with great local businesses</p>
          </div>

          <p className="fb-start" data-component-bound="true">
            <button
              onClick={(e) => {
                this.props.loginViaSocial('facebook')
              }}
              type="submit" value="submit" className="ybtn ybtn--social ybtn--facebook ybtn-full">
              <span>
                <div className="u-text-centered">
              <span id="login_facebook_icon"
                    aria-hidden="true"
                    className="icon icon--24-facebook icon--size-24 icon--currentColor">
                <svg className="icon_svg">
                  {/*<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#24x24_facebook"></use>*/}
                </svg>
              </span> Sign Up with Facebook</div>
              </span>
            </button>
          </p>

          <p className="legal-copy">Don't worry, we never post without your permission.</p>

          <fieldset className="hr-line">
            <legend >OR</legend>
          </fieldset>

          {this.renderForm()}

        </div>
        <div className="sub-text-box">
          <small className="subtle-text">{'Already on Yelp? '}
            <a onClick={(e) => {
              this.props.toggleEvent(e, LOGIN_FORM_TYPE_LOGIN)
            }}
               className="signup-link" href="/signup">{'Log in'}</a>
          </small>
        </div>
      </div>
    )
  }

  renderForm() {
    return (
      <form className="yform signup-form  city-hidden" id="signup-form" method="POST">
        <div className="js-password-meter-container" data-component-bound="true">
          <ul className="inline-layout clearfix">
            <li>
              <label className="placeholder-sub">First Name</label>
              <input id="first_name"
                     name="first_name"
                     placeholder="<NAME>"
                     required="required" type="text" value=""
                     className="login_input_email"/>
            </li>

            <li>
              <label className="placeholder-sub">Last Name</label>
              <input id="last_name" name="last_name" placeholder="<NAME>" required="required" type="text" value=""/>
            </li>

          </ul>
          <label className="placeholder-sub">Email</label>
          <input id="email" name="email" placeholder="Email" required="required" type="email" value=""/>

          <label className="placeholder-sub">Password</label>
          <input id="password" name="password" placeholder="Password" required="required" type="password" value=""
                 className="login_input_password"/>
        </div>

        <div className="captcha" id="signup-captcha"/>

        <p className="legal-copy legal-left">
            {'By signing up, you agree to Yelp’s '}
            <a className="legal-link" href="https://www.yelp.com.sg/static?p=tos">
                {'Terms of Service'}</a>
           {' and '} 
            <a className="legal-link" href="/tos/privacy_en_ie_20160131">Privacy Policy</a>{'.'}
        </p>
        <button id="signup-button" type="submit" value="Sign Up"
                className="ybtn ybtn--primary disable-on-submit submit signup-button">
          <span>Sign Up</span>
        </button>
      </form>
    )
  }
{'fraction_non_alphanumeric': 0.14652356509566028, 'fraction_numerical': 0.009519365375641624, 'mean_word_length': 2.113306217315514, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 153, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3103120', 'n_tokens_mistral': 3176, 'n_tokens_neox': 3035, 'n_words': 573}