<commit_before>import React, { Component } from 'react'
import t from '../../../translations'
import * as ACTIONS from '../../../actions'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import './quadraturerefinement.scss'

class QuadratureRefinement extends Component {
  constructor() {
    super()
  }

  render() {

    return (
      <div className="quadrature__refinement__wrapper">
        <h4>Квадратура: </h4>
        <div className='quadrature__inner__wrapper'>
          <div className='quadrature__from'>
            <span>От:</span>
            <button className='btn plus-button'> + </button>
            <input type='number' />
            <button className='btn minus-button'> - </button>
          </div>
          <div className='quadrature__to'>
            <span>До:</span>
            <button className='btn plus-button'> + </button>
            <input type='number' />
            <button className='btn minus-button'> - </button>
          </div>
        </div>
      </div>
    )
  }
}

function mapStateToProps(state) {
  // eslint-disable-line no-unused-vars
  /* Populated by react-webpack-redux:reducer */

  const props = {
  }
  return props
}

function mapDispatchToProps(dispatch) {
  /* Populated by react-webpack-redux:action */
  const actions = ACTIONS
  const actionMap = { actions: bindActionCreators(actions, dispatch) }
  return actionMap
}

export default connect(mapStateToProps, mapDispatchToProps)(QuadratureRefinement)<commit_msg>add quadrature refinement validation<commit_after>import React, { Component } from 'react'
import t from '../../../translations'
import * as ACTIONS from '../../../actions'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import './quadraturerefinement.scss'

class QuadratureRefinement extends Component {
  constructor() {
    super()
    this.state = {
      quadratureFrom: '',
      quadratureTo: ''
    }

    this.increaseFromQuadrature = this.increaseFromQuadrature.bind(this)
    this.increaseToQuadrature = this.increaseToQuadrature.bind(this)
    this.decreaseFromQuadrature = this.decreaseFromQuadrature.bind(this)
    this.decreaseToQuadrature = this.decreaseToQuadrature.bind(this)
  }

  increaseFromQuadrature() {
    const {
      quadratureFrom,
      quadratureTo
    } = this.state
    let quadrature = {}

    if (quadratureFrom === '') {
      quadrature.quadratureFrom = 10
    } else {
      quadrature.quadratureFrom = quadratureFrom + 10
    }

    if (quadrature.quadratureFrom >= quadratureTo) {
      quadrature.quadratureTo = quadrature.quadratureFrom + 10
    }

    this.setState(quadrature)
  }

  increaseToQuadrature() {
    const {
      quadratureTo
    } = this.state
    let newQuadrature = null

    if (quadratureTo === '') {
      newQuadrature = 10
    } else {
      newQuadrature = quadratureTo + 10
    }

    this.setState({
      quadratureTo: newQuadrature
    })
  }

  decreaseFromQuadrature() {
    const {
      quadratureFrom
    } = this.state

    let newQuadrature = null

    if (quadratureFrom === '') {
      return;
    } else if (quadratureFrom === 10) {
      newQuadrature = ''
    } else {
      newQuadrature = quadratureFrom - 10
    }

    this.setState({
      quadratureFrom: newQuadrature
    })
  }

  decreaseToQuadrature() {
    const {
      quadratureTo,
      quadratureFrom
    } = this.state

    let quadrature = {}

    if (quadratureTo === '') {
      return;
    } else if (quadratureTo === 10) {
      quadrature.quadratureTo = ''
    } else {
      quadrature.quadratureTo = quadratureTo - 10
    }

    if (quadrature.quadratureTo <= quadratureFrom) {
      if (quadratureFrom === 10 || quadratureFrom === '') {
        quadrature.quadratureFrom = ''
      } else {
        quadrature.quadratureFrom = quadratureFrom - 10
      }
    }

    this.setState(quadrature)
  }

  render() {
    const {
      quadratureTo,
      quadratureFrom
    } = this.state

    return (
      <div className="quadrature__refinement__wrapper">
        <h4>Квадратура: </h4>
        <div className='quadrature__inner__wrapper'>
          <div className='quadrature__from'>
            <span>От:</span>
            <button onClick={this.decreaseFromQuadrature} className='btn minus-button'> - </button>
            <input value={quadratureFrom} type='number' />
            <button onClick={this.increaseFromQuadrature} className='btn plus-button'> + </button>
          </div>
          <div className='quadrature__to'>
            <span>До:</span>
            <button onClick={this.decreaseToQuadrature} className='btn minus-button'> - </button>
            <input value={quadratureTo} type='number' />
            <button onClick={this.increaseToQuadrature} className='btn plus-button'> + </button>
          </div>
        </div>
      </div>
    )
  }
}

function mapStateToProps(state) {
  // eslint-disable-line no-unused-vars
  /* Populated by react-webpack-redux:reducer */

  const props = {
  }
  return props
}

function mapDispatchToProps(dispatch) {
  /* Populated by react-webpack-redux:action */
  const actions = ACTIONS
  const actionMap = { actions: bindActionCreators(actions, dispatch) }
  return actionMap
}

export default connect(mapStateToProps, mapDispatchToProps)(QuadratureRefinement)
{'fraction_non_alphanumeric': 0.12276743748824967, 'fraction_numerical': 0.0048881368678322995, 'mean_word_length': 2.656357388316151, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 52, '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': '5399102', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1648, 'n_words': 313}