<commit_before>import PropTypes from 'prop-types'
import React, { Component } from 'react'
import classnames from 'classnames'
import { isValidEmail } from '~client/utils/validation-helper'
import AnalyticsEvents from '~client/mobilizations/widgets/utils/analytics-events'

if (require('exenv').canUseDOM) require('./index.scss')

// TODO: Reusable Input
const controlClassname = 'px3 py1'
const inputReset = {
  border: 'none',
  padding: '0',
  height: '2rem',
  outline: 'none'
}

class PressureForm extends Component {
  constructor (props) {
    super(props)
    this.state = {
      email: '',
      name: '',
      lastname: '',
      city: '',
      subject: props.subject,
      body: props.body
    }
  }

  validate () {
    const { targetList, widget: { settings: { show_city: showCity } } } = this.props
    const requiredMsg = 'Preenchimento obrigatório'
    const errors = { valid: true }

    if (!this.state.email) {
      errors.email = requiredMsg
    } else if (!isValidEmail(this.state.email)) {
      errors.email = 'E-mail inválido'
    } else if (targetList.some(target => target.match(`<${this.state.email}>`))) {
      errors.email = 'O email que você está tentando usar é de um dos alvos da mobilização.'
    }
    if (!this.state.name) {
      errors.name = requiredMsg
    }
    if (!this.state.lastname) {<commit_msg>chore(pressure-widget): check if targetList is defined fix #728<commit_after>import PropTypes from 'prop-types'
import React, { Component } from 'react'
import classnames from 'classnames'
import { isValidEmail } from '~client/utils/validation-helper'
import AnalyticsEvents from '~client/mobilizations/widgets/utils/analytics-events'

if (require('exenv').canUseDOM) require('./index.scss')

// TODO: Reusable Input
const controlClassname = 'px3 py1'
const inputReset = {
  border: 'none',
  padding: '0',
  height: '2rem',
  outline: 'none'
}

class PressureForm extends Component {
  constructor (props) {
    super(props)
    this.state = {
      email: '',
      name: '',
      lastname: '',
      city: '',
      subject: props.subject,
      body: props.body
    }
  }

  validate () {
    const { targetList, widget: { settings: { show_city: showCity } } } = this.props
    const requiredMsg = 'Preenchimento obrigatório'
    const errors = { valid: true }

    if (!this.state.email) {
      errors.email = requiredMsg
    } else if (!isValidEmail(this.state.email)) {
      errors.email = 'E-mail inválido'
    } else if (targetList && targetList.some(target => target.match(`<${this.state.email}>`))) {
      errors.email = 'O email que você está tentando usar é de um dos alvos da mobilização.'
    }
    if (!this.state.name) {
      errors.name = requiredMsg
    }
    if (!this.state.lastname) {
{'fraction_non_alphanumeric': 0.13669325598259607, 'fraction_numerical': 0.003988397389412618, 'mean_word_length': 3.225114854517611, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5110648', 'n_tokens_mistral': 880, 'n_tokens_neox': 866, 'n_words': 224}