<commit_before>'use strict'

var React = require('react')
var Task = require('data.task')

var Search = require('../components/paying_in_search.js')
var PayingIn = require('../components/paying_in.js')
var Spinner = require('../../shared/spinner.js')

var curry = require('curry')
var object_assign = require('object-assign')
var get_data = require('app/get_data.js')
var chain = require('app/chain.js')
var map = require('app/map.js')
var dethunk = require('dethunking-compose')
var prop_or = require('app/prop_or.js')
var trace = require('app/trace.js')
var fold = require('app/fold.js')
var filter = require('app/filter.js')

module.exports = React.createClass({
  getInitialState: function () {
    return {
      payments: []
      , charges: {}
      , searching: false
    }
  },
  render: function () {
    var { get_payments, input_or_select, inputs } = this.props
    var { charges, payments, reference, searching } = this.state
    return (
      <div className='main-container'>
        <Search
            submit_handler={search(get_payments, this.setState.bind(this))}
            input_or_select={input_or_select}
            inputs={inputs} />
        { payments.length
            && number_of_keys(charges) > number_of_members(payments) - 10
              ? <PayingIn
                  payments={payments}
                  charges={charges}
                  reference={reference}
              />
              : searching
              ? <Spinner />
              : '' }
      </div> ) } })

var receive = curry(function (set_state, ref, charges, payments) {
  set_state({ ref: ref, charges: charges, payments: payments }) })

var search = curry(function search (get_payments, set_state, e) {
  e.preventDefault()
  var payments = get_payments(e)

  payments.fork(trace('payments error'), receive_payments(set_state)) })

var receive_payments = curry((set_state, match_ref) => {
  var charges = make_charges(match_ref)
  var charge_data = {}
  var update_data = more_data => object_assign(charge_data, more_data)

  set_state({ payments: match_ref, searching: true })

  // Ap doesn't work nicely for data.Task
  // going to mutate! :cry:
  charges.forEach(member_charges =>
    member_charges.fork(trace('charge error'), dethunk(
        () => set_charges(set_state)
        , () => update_data ) )) })

var get_member_charges = id =>
  get_data('api/payments/?member=' + id).map(member_charges =>
      ({ [id]: member_charges }))<commit_msg>punctuation<commit_after>'use strict'

var React = require('react')
var Task = require('data.task')

var Search = require('../components/paying_in_search.js')
var PayingIn = require('../components/paying_in.js')
var Spinner = require('../../shared/spinner.js')

var curry = require('curry')
var object_assign = require('object-assign')
var get_data = require('app/get_data.js')
var chain = require('app/chain.js')
var map = require('app/map.js')
var dethunk = require('dethunking-compose')
var prop_or = require('app/prop_or.js')
var trace = require('app/trace.js')
var fold = require('app/fold.js')
var filter = require('app/filter.js')

module.exports = React.createClass({
  getInitialState: function () {
    return {
      payments: []
      , charges: {}
      , searching: false
    }
  },
  render: function () {
    var { get_payments, input_or_select, inputs } = this.props
    var { charges, payments, reference, searching } = this.state
    return (
      <div className='main-container'>
        <Search
            submit_handler={search(get_payments, this.setState.bind(this))}
            input_or_select={input_or_select}
            inputs={inputs} />
        { payments.length
            && number_of_keys(charges) > number_of_members(payments) - 10
              ? <PayingIn
                  payments={payments}
                  charges={charges}
                  reference={reference}
              />
              : searching
              ? <Spinner />
              : '' }
      </div> ) } })

var receive = curry((set_state, ref, charges, payments) =>
  set_state({ ref: ref, charges: charges, payments: payments }))

var search = curry(function search (get_payments, set_state, e) {
  e.preventDefault()
  var payments = get_payments(e)

  payments.fork(trace('payments error'), receive_payments(set_state)) })

var receive_payments = curry((set_state, match_ref) => {
  var charges = make_charges(match_ref)
  var charge_data = {}
  var update_data = (more_data) => object_assign(charge_data, more_data)

  set_state({ payments: match_ref, searching: true })

  // Ap doesn't work nicely for data.Task
  // going to mutate! :cry:
  charges.forEach((member_charges) =>
    member_charges.fork(trace('charge error'), dethunk(
        () => set_charges(set_state)
        , () => update_data ) )) })

var get_member_charges = (id) =>
  get_data('api/payments/?member=' + id).map(member_charges =>
      ({ [id]: member_charges }))
{'fraction_non_alphanumeric': 0.1437855402112104, 'fraction_numerical': 0.0008123476848090983, 'mean_word_length': 3.0668868703550785, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, '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': '3073305', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1525, 'n_words': 315}