<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import reqwest from 'reqwest';
import isemail from 'isemail';
import styled from 'styled-components';

import TextInput from 'grommet/components/TextInput';
import Form from 'grommet/components/Form';
import FormField from 'grommet/components/FormField';

import SplashButton from '../SplashButton';



const { string } = PropTypes;

//scrantonhacks.us16.list-manage.com/subscribe/post?u=5d0b0c770c04055d190170b52&amp;id=27660098a2" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form
const FormContainer = styled.div`
  color: #fff;
  text-align: center;
`;

const StyledText = styled.p`
  color: #fff !important;
  text-align: center;
  max-width: 100% !important;
`;

const SubscribeForm = styled(Form)`
  width: 100% !important;
`;

const InputField = styled(TextInput)`
  width: 23.3em;
  background-color: rgba(73, 69, 82, 0.8) !important;
`;

export default class MailchimpForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      valid: false,
      isTyping: false,
      submitted: false,
      buttonValue: props.buttonValue,
      showError: props.showError,
      completeMessage: props.completeMessage,
      helpText: props.helpText
    }
    this.validateEmail = this.validateEmail.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
    this.getValid = this.getValid.bind(this);
  }

  static get defaultProps () {
    return {
      buttonValue: 'Subscribe',
      buttonStyles: 'button',
      placeholder: 'Email Address',
      completeMessage: 'Thanks for subscribing',
      helpText: 'Please provide a valid email address',
      showError: true,
      emailAddress: '',
      action: null
    }
  }

  handleSubmit(e) {
    e.preventDefault();
    let self = this;
    let isValid = this.state.valid;

    if (isValid) {
      reqwest({
        method: 'get',
        type: 'jsonp',
        contentType: 'application/json',
        url: this.state.mailChimpUrl,
        data: {EMAIL: this.state.emailAddress, STATUS: 'subscribed'},
        jsonpCallback: 'c'
      })
      .then(function (resp) {
        self.setState({
          submitted: true
        })<commit_msg>fixed action in subscribe form<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import reqwest from 'reqwest';
import isemail from 'isemail';
import styled from 'styled-components';

import TextInput from 'grommet/components/TextInput';
import Form from 'grommet/components/Form';
import FormField from 'grommet/components/FormField';

import SplashButton from '../SplashButton';



const { string } = PropTypes;

//scrantonhacks.us16.list-manage.com/subscribe/post?u=5d0b0c770c04055d190170b52&amp;id=27660098a2" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form
const FormContainer = styled.div`
  color: #fff;
  text-align: center;
`;

const StyledText = styled.p`
  color: #fff !important;
  text-align: center;
  max-width: 100% !important;
`;

const SubscribeForm = styled(Form)`
  width: 100% !important;
`;

const InputField = styled(TextInput)`
  width: 23.3em;
  background-color: rgba(73, 69, 82, 0.8) !important;
`;

export default class MailchimpForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      valid: false,
      isTyping: false,
      submitted: false,
      buttonValue: props.buttonValue,
      showError: props.showError,
      completeMessage: props.completeMessage,
      helpText: props.helpText,
      action: props.action,
    }
    this.validateEmail = this.validateEmail.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
    this.getValid = this.getValid.bind(this);
  }

  static get defaultProps () {
    return {
      buttonValue: 'Subscribe',
      buttonStyles: 'button',
      placeholder: 'Email Address',
      completeMessage: 'Thanks for subscribing',
      helpText: 'Please provide a valid email address',
      showError: true,
      emailAddress: '',
      action: null
    }
  }

  handleSubmit(e) {
    console.log(this.state.action);
    e.preventDefault();
    let self = this;
    let isValid = this.state.valid;

    if (isValid) {
      reqwest({
        method: 'get',
        type: 'jsonp',
        contentType: 'application/json',
        url: this.state.action,
        data: {EMAIL: this.state.emailAddress, STATUS: 'subscribed'},
        jsonpCallback: 'c'
      })
      .then(function (resp) {
        self.setState({
          submitted: true
        })
{'fraction_non_alphanumeric': 0.12304347826086956, 'fraction_numerical': 0.02043478260869565, 'mean_word_length': 3.2839851024208566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5003071', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1444, 'n_words': 339}