aboutsummaryrefslogtreecommitdiff
path: root/src/settings/reducers/setting.js
blob: 54033aa55c9401d3b4f80632cdb28cbd6e94bec8 (plain) (blame)
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
import actions from 'settings/actions';

const defaultState = {
  source: '',
  json: '',
  form: null,
  error: '',
};

export default function reducer(state = defaultState, action = {}) {
  switch (action.type) {
  case actions.SETTING_SET_SETTINGS:
    return { ...state,
      source: action.source,
      json: action.json,
      form: action.form,
      error: '', };
  case actions.SETTING_SHOW_ERROR:
    return { ...state,
      error: action.error,
      json: action.json, };
  case actions.SETTING_SWITCH_TO_FORM:
    return { ...state,
      error: '',
      source: 'form',
      form: action.form, };
  case actions.SETTING_SWITCH_TO_JSON:
    return { ...state,
      error: '',
      source: 'json',
      json: action.json, };
  default:
    return state;
  }
}