Example #1
0
 it('should return axios types', () => {
   generateAsyncTypes(type).should.eql({
     request: 'request',
     success: `request_${successSuffix}`,
     error: `request_${errorSuffix}`
   });
 });
Example #2
0
import clone from 'lodash/clone';
import { handleActions } from 'redux-actions';

import { LOGIN, GET_ACCOUNT } from 'actions/authActions';
import { EMAIL_CHANGED } from 'actions/accountSettingActions';
import { generateAsyncTypes } from 'actions/async';

const { success } = generateAsyncTypes(LOGIN);
const getAccountSuccess = generateAsyncTypes(GET_ACCOUNT).success;

export default handleActions({
  [success]: (state, action) => (action.payload.user),
  [getAccountSuccess]: (state, action) => (action.payload.user),
  [EMAIL_CHANGED]: (state, action) => {
    const newState = clone(state);
    newState.account_profile = newState.account_profile.slice(0);
    newState.account_profile[0].email_address = action.payload;
    return newState;
  }
}, {});
Example #3
0
import { handleActions } from 'redux-actions';
import assign from 'lodash/assign';

import { GET_TRANSACTION_BY_ID } from 'actions/transactionActions';
import { GET_TRANSACTION } from 'actions/transactionActions';
import { generateAsyncTypes } from 'actions/async';

const { success } = generateAsyncTypes(GET_TRANSACTION_BY_ID);
const getTransactionSuccess = generateAsyncTypes(GET_TRANSACTION).success;

export default handleActions({
  [success]: (state, action) => (assign({}, state, action.payload)),
  [getTransactionSuccess]: (state, action) => (assign({}, state, action.payload))
}, {});