summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/redux/modules/initForm.js
blob: 82bd90b966b6f879cfd4d05e4393900a9099e3da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { fromJS, Map } from 'immutable';
import { INIT, CLEAR } from 'ba-actions/actionTypes';

const initialState = {
  formValues: Map()
};

const initialImmutableState = fromJS(initialState);
export default function reducer(state = initialImmutableState, action = {}) {
  switch (action.type) {
    case INIT:
      return state.withMutations((mutableState) => {
        mutableState.set('formValues', action.data);
      });
    case CLEAR:
      return state.withMutations((mutableState) => {
        mutableState.set('formValues', []);
      });
    default:
      return state;
  }
}