<commit_before>import React, { Component } from 'react'
import PropTypes from 'prop-types'
// redux
import { connect } from 'react-redux'
import { toggleComingSoonModal } from 'store/modules/ui/comingSoonModal'
import { submitPayment } from 'store/modules/payment'
import { formValueSelector } from 'redux-form'
// libs
import { fx } from 'money'
import { toastr } from 'react-redux-toastr'
// components
import RaisedButton from 'material-ui/RaisedButton'
import ComingSoon from 'components/ComingSoon'
import CustomerWalletForm from './CustomerWalletForm'
// utils
import { getExchangeRates } from 'utils/exchangeReq'
// styles
import './CustomerWallet.css'
// assets
import { buttonsData } from './data'

class CustomerWalletComponent extends Component {

  componentWillMount () {
    getExchangeRates().then((data) => {
      if (data) {
        fx.rates = data.rates
        fx.base = data.base
      }
    })
  }

  handleSubmit (data) {
<<<<<<< HEAD
    const { submitPayment } = this.props
    submitPayment(data)
      .then((response) => {
        console.log(response)
        toastr.success('success', 'Payment success')
      })
=======
    console.log('sending payment with the following... ')
    console.log(data)
>>>>>>> 70d9c14... Use coin select to find outputs to spend and calculate fees
  }

  render() {
    const { toggleModal, modalOpen, isReviewOpen } = this.props
    return (
      <div className='customer-wallet-form'>
        <h3>Payment for Shinny New Toy $400</h3>
        <div className='select-crypto'>
          <p>Select the currency you want pay in</p>
          {buttonsData.map(({ label, disabled }, idx) => (
            <RaisedButton
              key={idx}
              label={label}
              primary
              disabled={disabled}
              className='btn__crypto-selector'
              onClick={toggleModal}
            />
          ))}
          <CustomerWalletForm
            onSubmit={this.handleSubmit}
            isReviewOpen={isReviewOpen}
          />
        </div>
        <ComingSoon
          open={modalOpen}
          closeModal={toggleModal}
        />
      </div>
    )
  }
}

CustomerWalletComponent.propTypes = {
  toggleModal: PropTypes.func.isRequired,
<<<<<<< HEAD
  submitPayment: PropTypes.func.isRequired,
=======
>>>>>>> 70d9c14... Use coin select to find outputs to spend and calculate fees
  modalOpen: PropTypes.bool.isRequired,
  isReviewOpen: PropTypes.bool
}


const selector = formValueSelector('customer-wallet-form')

const mapStateToProps = state => ({
  modalOpen: state.ui.comingSoonModal.open,
  isReviewOpen: selector(state, 'reviewOpen')
})

const mapDispatchToProps = dispatch => ({
  toggleModal: () => dispatch(toggleComingSoonModal()),
  submitPayment: data => dispatch(submitPayment(data))
})

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(CustomerWalletComponent)
<commit_msg>added apiClient and integrate it with thunk middleware, added payment reducer and connected submit thunk to payment form, with success response and toastr, added supporting absolute project paths<commit_after>import React, { Component } from 'react'
import PropTypes from 'prop-types'
// redux
import { connect } from 'react-redux'
import { toggleComingSoonModal } from 'store/modules/ui/comingSoonModal'
import { submitPayment } from 'store/modules/payment'
import { formValueSelector } from 'redux-form'
// libs
import { fx } from 'money'
import { toastr } from 'react-redux-toastr'
// components
import RaisedButton from 'material-ui/RaisedButton'
import ComingSoon from 'components/ComingSoon'
import CustomerWalletForm from './CustomerWalletForm'
// utils
import { getExchangeRates } from 'utils/exchangeReq'
// styles
import './CustomerWallet.css'
// assets
import { buttonsData } from './data'

class CustomerWalletComponent extends Component {

  componentWillMount () {
    getExchangeRates().then((data) => {
      if (data) {
        fx.rates = data.rates
        fx.base = data.base
      }
    })
  }

  handleSubmit (data) {
    const { submitPayment } = this.props
    submitPayment(data)
      .then((response) => {
        console.log(response)
        toastr.success('success', 'Payment success')
      })
  }

  render() {
    const { toggleModal, modalOpen, isReviewOpen } = this.props
    return (
      <div className='customer-wallet-form'>
        <h3>Payment for Shinny New Toy $400</h3>
        <div className='select-crypto'>
          <p>Select the currency you want pay in</p>
          {buttonsData.map(({ label, disabled }, idx) => (
            <RaisedButton
              key={idx}
              label={label}
              primary
              disabled={disabled}
              className='btn__crypto-selector'
              onClick={toggleModal}
            />
          ))}
          <CustomerWalletForm
            onSubmit={this.handleSubmit}
            isReviewOpen={isReviewOpen}
          />
        </div>
        <ComingSoon
          open={modalOpen}
          closeModal={toggleModal}
        />
      </div>
    )
  }
}

CustomerWalletComponent.propTypes = {
  toggleModal: PropTypes.func.isRequired,
  submitPayment: PropTypes.func.isRequired,
  modalOpen: PropTypes.bool.isRequired,
  isReviewOpen: PropTypes.bool
}


const selector = formValueSelector('customer-wallet-form')

const mapStateToProps = state => ({
  modalOpen: state.ui.comingSoonModal.open,
  isReviewOpen: selector(state, 'reviewOpen')
})

const mapDispatchToProps = dispatch => ({
  toggleModal: () => dispatch(toggleComingSoonModal()),
  submitPayment: data => dispatch(submitPayment(data))
})

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(CustomerWalletComponent)

{'fraction_non_alphanumeric': 0.11838879159369527, 'fraction_numerical': 0.0035026269702276708, 'mean_word_length': 2.933195592286501, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 53, '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': '1457702', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1608, 'n_words': 381}