aboutsummaryrefslogtreecommitdiff
path: root/src/settings/reducers/setting.js
blob: 8e4a415f4af4121400e371bfc8f20a128015b291 (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
36
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,
      errors: '',
      error: '', };
  case actions.SETTING_SHOW_ERROR:
    return { ...state,
      error: action.text,
      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;
  }
}