<commit_before>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { ScrollView, View, Text, Keyboard } from 'react-native'
import { FormLabel, FormInput, Button, ButtonGroup } from 'react-native-elements'
import { connect } from 'react-redux'
import { isEmpty } from 'lodash'
import { format } from 'date-fns'

import SimplePicker from '../../components/SimplePicker'

import actions from '../../actions'
import { categories } from '../../constants'
import colors from '../../styles/shared/variables.styles'

import styles from './AddOrEditOperation.styles'

class AddOrEditOperation extends Component {
  static propTypes = {
    dispatch: PropTypes.func.isRequired,
    navigator: PropTypes.object.isRequired,
    route: PropTypes.object.isRequired,
  }

  static route = {
    navigationBar: { title: 'Add new operation' }
  }

  state = {
    type: 'debit',
    label: '',
    category: '',
    amount: '',
  }

  handleChangeType = index => {
    const buttons = ['debit', 'credit']

    this.setState({ type: buttons[index] })
  }

  handleChangeInput = (key, value) => this.setState({ [key]: value })

  togglePicker = type => {
    Keyboard.dismiss()
    this._picker.togglePicker()
  }

  addNewOperation = async () => {
    const { dispatch, navigator, route: { params } } = this.props
    const { amount: nb, type } = this.state
    const amount = nb.replace(',', '.')

    dispatch(actions.accounts.addNewOperation(params._id, {
      ...this.state,
      amount: parseFloat(type === 'debit' ? `-${amount}` : amount),
      date: format(new Date(), 'DD/MM/YYYY'),
    }))
    navigator.pop()
  }

  render () {
    const buttons = ['debit', 'credit']
    const { type, label, category, amount } = this.state
    const isDisabled = isEmpty(label) || isEmpty(amount)
    const defaultOptions = {
      placeholderTextColor: colors.beige,
      spellCheck: false,
    }

    return (
      <ScrollView style={styles.AddOrEditOperation}>
        <ButtonGroup
          buttons={buttons}
          onPress={this.handleChangeType}
          selectedIndex={buttons.findIndex(el => el === type)}
          containerStyle={styles.ButtonsGroup}
          buttonStyle={styles.TypeButtons}
          selectedBackgroundColor={colors.pistache}
          selectedTextStyle={styles.selectedText}
          innerBorderStyle={styles.innerBorder}
        />
        <FormLabel>Label</FormLabel>
        <FormInput
          value={label}
          placeholder="Bouygues mobile"
          onChangeText={value => this.handleChangeInput('label', value)}
          {...defaultOptions}
          autoFocus
        />

        <FormLabel>Category</FormLabel>
        <FormInput
          value={category}
          placeholder="Abonnements"
          onFocus={this.togglePicker}
          {...defaultOptions}
        />

        <FormLabel>Amount</FormLabel>
        <FormInput
          value={amount.toString()}
          placeholder="0,00"
          defaultValue="0"
          keyboardType="decimal-pad"
          onChangeText={value => this.handleChangeInput('amount', value)}
          {...defaultOptions}
        />

        <Button
          icon={{ name: 'ios-add-circle-outline', type: 'ionicon' }}
          title='Add this operation'
          onPress={this.addNewOperation}
          buttonStyle={styles.AddButton}
          disabledStyle={styles.DisabledButton}
          disabled={isDisabled}
        />

        <View style={styles.infos}>
          <Text style={styles.instructions}>
            All fields but category are required
          </Text>
        </View>

        <SimplePicker
          ref={p => this._picker = p}
          options={categories}
          onSubmit={value => this.handleChangeInput('category', value)}
          confirmText="Select"
        />
      </ScrollView>
    )
  }
}<commit_msg>[UPD] Remove confirmText Props on SimplePicker<commit_after>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { ScrollView, View, Text, Keyboard } from 'react-native'
import { FormLabel, FormInput, Button, ButtonGroup } from 'react-native-elements'
import { connect } from 'react-redux'
import { isEmpty } from 'lodash'
import { format } from 'date-fns'

import SimplePicker from '../../components/SimplePicker'

import actions from '../../actions'
import { categories } from '../../constants'
import colors from '../../styles/shared/variables.styles'

import styles from './AddOrEditOperation.styles'

class AddOrEditOperation extends Component {
  static propTypes = {
    dispatch: PropTypes.func.isRequired,
    navigator: PropTypes.object.isRequired,
    route: PropTypes.object.isRequired,
  }

  static route = {
    navigationBar: { title: 'Add new operation' }
  }

  state = {
    type: 'debit',
    label: '',
    category: '',
    amount: '',
  }

  handleChangeType = index => {
    const buttons = ['debit', 'credit']

    this.setState({ type: buttons[index] })
  }

  handleChangeInput = (key, value) => this.setState({ [key]: value })

  togglePicker = type => {
    Keyboard.dismiss()
    this._picker.togglePicker()
  }

  addNewOperation = async () => {
    const { dispatch, navigator, route: { params } } = this.props
    const { amount: nb, type } = this.state
    const amount = nb.replace(',', '.')

    dispatch(actions.accounts.addNewOperation(params._id, {
      ...this.state,
      amount: parseFloat(type === 'debit' ? `-${amount}` : amount),
      date: format(new Date(), 'DD/MM/YYYY'),
    }))
    navigator.pop()
  }

  render () {
    const buttons = ['debit', 'credit']
    const { type, label, category, amount } = this.state
    const isDisabled = isEmpty(label) || isEmpty(amount)
    const defaultOptions = {
      placeholderTextColor: colors.beige,
      spellCheck: false,
    }

    return (
      <ScrollView style={styles.AddOrEditOperation}>
        <ButtonGroup
          buttons={buttons}
          onPress={this.handleChangeType}
          selectedIndex={buttons.findIndex(el => el === type)}
          containerStyle={styles.ButtonsGroup}
          buttonStyle={styles.TypeButtons}
          selectedBackgroundColor={colors.pistache}
          selectedTextStyle={styles.selectedText}
          innerBorderStyle={styles.innerBorder}
        />
        <FormLabel>Label</FormLabel>
        <FormInput
          value={label}
          placeholder="Bouygues mobile"
          onChangeText={value => this.handleChangeInput('label', value)}
          {...defaultOptions}
          autoFocus
        />

        <FormLabel>Category</FormLabel>
        <FormInput
          value={category}
          placeholder="Abonnements"
          onFocus={this.togglePicker}
          {...defaultOptions}
        />

        <FormLabel>Amount</FormLabel>
        <FormInput
          value={amount.toString()}
          placeholder="0,00"
          defaultValue="0"
          keyboardType="decimal-pad"
          onChangeText={value => this.handleChangeInput('amount', value)}
          {...defaultOptions}
        />

        <Button
          icon={{ name: 'ios-add-circle-outline', type: 'ionicon' }}
          title='Add this operation'
          onPress={this.addNewOperation}
          buttonStyle={styles.AddButton}
          disabledStyle={styles.DisabledButton}
          disabled={isDisabled}
        />

        <View style={styles.infos}>
          <Text style={styles.instructions}>
            All fields but category are required
          </Text>
        </View>

        <SimplePicker
          ref={p => this._picker = p}
          options={categories}
          onSubmit={value => this.handleChangeInput('category', value)}
        />
      </ScrollView>
    )
  }
}
{'fraction_non_alphanumeric': 0.13408618899273106, 'fraction_numerical': 0.0010384215991692627, 'mean_word_length': 2.4754172304916553, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 57, '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': '4552949', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2138, 'n_words': 450}