all files / src/ actions.js

100% Statements 44/44
100% Branches 6/6
100% Functions 17/17
100% Lines 22/22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58     18×         18×     34×             45× 45×   42×                     12×     12×             32×     13×    
import { ADD_ARRAY_VALUE, AUTOFILL, BLUR, CHANGE, DESTROY, FOCUS, INITIALIZE, REMOVE_ARRAY_VALUE, RESET, START_ASYNC_VALIDATION,
  START_SUBMIT, STOP_ASYNC_VALIDATION, STOP_SUBMIT, SUBMIT_FAILED, SWAP_ARRAY_VALUES, TOUCH, UNTOUCH } from './actionTypes';
 
export const addArrayValue = (path, value, index, fields) =>
  ({type: ADD_ARRAY_VALUE, path, value, index, fields});
 
export const autofill = (field, value) =>
  ({type: AUTOFILL, field, value});
 
export const blur = (field, value) =>
  ({type: BLUR, field, value});
 
export const change = (field, value) =>
  ({type: CHANGE, field, value});
 
export const destroy = () =>
  ({type: DESTROY});
 
export const focus = field =>
  ({type: FOCUS, field});
 
export const initialize = (data, fields, overwriteValues = true) => {
  if (!Array.isArray(fields)) {
    throw new Error('must provide fields array to initialize() action creator');
  }
  return {type: INITIALIZE, data, fields, overwriteValues};
};
 
export const removeArrayValue = (path, index) =>
  ({type: REMOVE_ARRAY_VALUE, path, index});
 
export const reset = () =>
  ({type: RESET});
 
export const startAsyncValidation = field =>
  ({type: START_ASYNC_VALIDATION, field});
 
export const startSubmit = () =>
  ({type: START_SUBMIT});
 
export const stopAsyncValidation = errors =>
  ({type: STOP_ASYNC_VALIDATION, errors});
 
export const stopSubmit = errors =>
  ({type: STOP_SUBMIT, errors});
 
export const submitFailed = () =>
  ({type: SUBMIT_FAILED});
 
export const swapArrayValues = (path, indexA, indexB) =>
  ({type: SWAP_ARRAY_VALUES, path, indexA, indexB});
 
export const touch = (...fields) =>
  ({type: TOUCH, fields});
 
export const untouch = (...fields) =>
  ({type: UNTOUCH, fields});