<commit_before>import { Component, PropTypes } from "react"
import ReactDom from "react-dom"

import { Controls, Forms } from "../../../../core/components"
import { Validate } from "../../../../core/util"

export default class Billing extends Component {

  static propTypes = {
    data: PropTypes.object.isRequired,
    save: PropTypes.func.isRequired,
    errors: PropTypes.object.isRequired,
    clear: PropTypes.func.isRequired,
    next: PropTypes.func.isRequired,
    states: PropTypes.array,
  }


  header = () => {
    return (
      <h4 className="text-center">
        Billing Address
      </h4>
    )
  }

  streetAddress = (value) => {
    const isValid = value.length ? true : false

    if (!isValid ) {
      this.props.clear("billing", "streetAddress")
    } else {
      this.props.save({ billing: { streetAddress: value }})
    }

    return true
  }

  streetAddress2 = (value) => {
    this.props.save({ billing: { streetAddress2: value }})
    return true
  }

  saveState = (value) => {
    // we can't require city for international giving

    if (!value.length) {
      this.props.clear("billing", "state")
    } else {
      this.props.save({ billing: { state: value }})
    }

    return true
  }

  saveCountry = (value) => {
    const isValid = value.length ? true : false

    if (!isValid ) {
      this.props.clear("billing", "country")
    } else {
      this.props.save({ billing: { country: value }})
    }

    return true
  }

  city = (value) => {

    if (!value.length) {
      this.props.clear("billing", "city")
    } else {
      this.props.save({ billing: { city: value }})
    }

    return true
  }

  zip = (value) => {

    // we can't require zip for international giving
    if (!value.length ) {
      this.props.clear("billing", "zip")
    } else {
      this.props.save({ billing: { zip: value }})
    }

    return true
  }

  render () {
    const { billing } = this.props.data
    const { states, countries } = this.props
    return (
      <div>
        <div className="push-double@lap-and-up push">
          {this.props.header || this.header()}
        </div>

        {this.props.children}

        <div className="soft">


          <Forms.Input
            name="streetAddress"
            label="Street Address"
            errorText="Please enter your address"
            validation={this.streetAddress}
            defaultValue={billing.streetAddress}
            ref="streetAddress"
            autofocus={true}
          />
          <Forms.Input
            name="streetAddress2"
            label="Street Address (optional)"
            validation={this.streetAddress2}
            defaultValue={billing.streetAddress2}
            ref="streetAddress2"
          />

          <Forms.Select
            name="country"
            label="Country"
            errorText="Please enter your country"
            defaultValue={billing.country ? billing.country : "US"}
            items={countries}
            validation={this.saveCountry}
            ref="country"
            includeBlank={true}
          />

          <Forms.Input
            name="city"
            label="City"
            errorText="Please enter your city"
            defaultValue={billing.city}
            validation={this.city}
            ref="city"
          />

          <div className="grid">
            {() => {
              if (!billing.country || billing.country === "US" || billing.country === "CA") {
                return (
                  <div className="grid__item one-half">
                    <Forms.Select
                      name="state"
                      label="State/Territory"
                      errorText="Please enter your state"
                      defaultValue={billing.state ? billing.state : "SC"}
                      items={states}
                      validation={this.saveState}
                      ref="state"
                      includeBlank={true}
                    />
                  </div>
                )
              }
            }()}
            {() => {
              let length = "one-whole"
              if (!billing.country || billing.country === "US" || billing.country === "CA") {
                length = "one-half"
              }
              return (
                <div className={`grid__item ${length}`}>
                  <Forms.Input
                    name="zip"
                    label="Zip/Postal"
                    type="tel"
                    errorText="Please enter your zip"
                    defaultValue={billing.zip}
                    onChange={this.zip}
                    validation={this.zip}
                    ref="zip"
                    maxLength="5"
                  />
                </div>
              )
            }()}


          </div>

        </div>



        <div>
          <a href="#" tabIndex={-1} onClick={this.props.back} className="btn--small btn--dark-tertiary display-inline-block">
            Back
          </a><commit_msg>remove max length on zip<commit_after>import { Component, PropTypes } from "react"
import ReactDom from "react-dom"

import { Controls, Forms } from "../../../../core/components"
import { Validate } from "../../../../core/util"

export default class Billing extends Component {

  static propTypes = {
    data: PropTypes.object.isRequired,
    save: PropTypes.func.isRequired,
    errors: PropTypes.object.isRequired,
    clear: PropTypes.func.isRequired,
    next: PropTypes.func.isRequired,
    states: PropTypes.array,
  }


  header = () => {
    return (
      <h4 className="text-center">
        Billing Address
      </h4>
    )
  }

  streetAddress = (value) => {
    const isValid = value.length ? true : false

    if (!isValid ) {
      this.props.clear("billing", "streetAddress")
    } else {
      this.props.save({ billing: { streetAddress: value }})
    }

    return true
  }

  streetAddress2 = (value) => {
    this.props.save({ billing: { streetAddress2: value }})
    return true
  }

  saveState = (value) => {
    // we can't require city for international giving

    if (!value.length) {
      this.props.clear("billing", "state")
    } else {
      this.props.save({ billing: { state: value }})
    }

    return true
  }

  saveCountry = (value) => {
    const isValid = value.length ? true : false

    if (!isValid ) {
      this.props.clear("billing", "country")
    } else {
      this.props.save({ billing: { country: value }})
    }

    return true
  }

  city = (value) => {

    if (!value.length) {
      this.props.clear("billing", "city")
    } else {
      this.props.save({ billing: { city: value }})
    }

    return true
  }

  zip = (value) => {

    // we can't require zip for international giving
    if (!value.length ) {
      this.props.clear("billing", "zip")
    } else {
      this.props.save({ billing: { zip: value }})
    }

    return true
  }

  render () {
    const { billing } = this.props.data
    const { states, countries } = this.props
    return (
      <div>
        <div className="push-double@lap-and-up push">
          {this.props.header || this.header()}
        </div>

        {this.props.children}

        <div className="soft">


          <Forms.Input
            name="streetAddress"
            label="Street Address"
            errorText="Please enter your address"
            validation={this.streetAddress}
            defaultValue={billing.streetAddress}
            ref="streetAddress"
            autofocus={true}
          />
          <Forms.Input
            name="streetAddress2"
            label="Street Address (optional)"
            validation={this.streetAddress2}
            defaultValue={billing.streetAddress2}
            ref="streetAddress2"
          />

          <Forms.Select
            name="country"
            label="Country"
            errorText="Please enter your country"
            defaultValue={billing.country ? billing.country : "US"}
            items={countries}
            validation={this.saveCountry}
            ref="country"
            includeBlank={true}
          />

          <Forms.Input
            name="city"
            label="City"
            errorText="Please enter your city"
            defaultValue={billing.city}
            validation={this.city}
            ref="city"
          />

          <div className="grid">
            {() => {
              if (!billing.country || billing.country === "US" || billing.country === "CA") {
                return (
                  <div className="grid__item one-half">
                    <Forms.Select
                      name="state"
                      label="State/Territory"
                      errorText="Please enter your state"
                      defaultValue={billing.state ? billing.state : "SC"}
                      items={states}
                      validation={this.saveState}
                      ref="state"
                      includeBlank={true}
                    />
                  </div>
                )
              }
            }()}
            {() => {
              let length = "one-whole"
              if (!billing.country || billing.country === "US" || billing.country === "CA") {
                length = "one-half"
              }
              return (
                <div className={`grid__item ${length}`}>
                  <Forms.Input
                    name="zip"
                    label="Zip/Postal"
                    type="tel"
                    errorText="Please enter your zip"
                    defaultValue={billing.zip}
                    onChange={this.zip}
                    validation={this.zip}
                    ref="zip"
                  />
                </div>
              )
            }()}


          </div>

        </div>



        <div>
          <a href="#" tabIndex={-1} onClick={this.props.back} className="btn--small btn--dark-tertiary display-inline-block">
            Back
          </a>
{'fraction_non_alphanumeric': 0.13066080175947214, 'fraction_numerical': 0.0018994301709487154, 'mean_word_length': 1.4652538196155742, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 65, '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': '115434', 'n_tokens_mistral': 2784, 'n_tokens_neox': 2628, 'n_words': 548}