daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Feb 14th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { connect } from 'react-redux'
  2.  
  3. import { URL, RP, C } from '../constants'
  4. import { updateRegisterStatus } from '../actions'
  5. import { fetchApi } from '../helpers'
  6. import { accountCreateRequest, accountCreateSuccess } from '../actions'
  7. import CreateAccountComponent from '../components/CreateAccountComponent'
  8.  
  9. const mapStateToProps = state => {
  10.   return {
  11.     authProcessing: state.authReducer.processing,
  12.     registerStepperStatus: state.authReducer.registerStepperStatus,
  13.     authError: state.authReducer.error || '',
  14.     accessToken: state.authReducer.accessToken
  15.   }
  16. }
  17.  
  18. const mapDispatchToProps = dispatch => {
  19.   return {
  20.     fetchAccountCreate: (successCallback, errorCallback) => {
  21.       dispatch(accountCreateRequest())
  22.  
  23.       fetchApi(URL.URL_ACCT_CREATE, {inclSummary: false},
  24.         res => {
  25.           dispatch(accountCreateSuccess())
  26.  
  27.           res.success
  28.             ? successCallback(res.data)
  29.             : errorCallback(res.errorCode, res.errorDescription);
  30.         },
  31.         err => errorCallback(err)
  32.       )
  33.     }
  34.   }
  35. }
  36.  
  37. const CreateAccountContainer = connect(
  38.   mapStateToProps,
  39.   mapDispatchToProps
  40. )(CreateAccountComponent)
  41.  
  42. export default CreateAccountContainer
RAW Paste Data
Top