diff options
Diffstat (limited to 'src/settings/reducers')
-rw-r--r-- | src/settings/reducers/setting.ts (renamed from src/settings/reducers/setting.js) | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/settings/reducers/setting.js b/src/settings/reducers/setting.ts index 54033aa..c4a21c7 100644 --- a/src/settings/reducers/setting.js +++ b/src/settings/reducers/setting.ts @@ -1,13 +1,25 @@ -import actions from 'settings/actions'; +import * as actions from '../actions'; +import { + JSONSettings, FormSettings, SettingSource, +} from '../../shared/SettingData'; -const defaultState = { - source: '', - json: '', - form: null, +export interface State { + source: SettingSource; + json?: JSONSettings; + form?: FormSettings; + error: string; +} + +const defaultState: State = { + source: SettingSource.JSON, + json: JSONSettings.valueOf(''), error: '', }; -export default function reducer(state = defaultState, action = {}) { +export default function reducer( + state = defaultState, + action: actions.SettingAction, +): State { switch (action.type) { case actions.SETTING_SET_SETTINGS: return { ...state, @@ -22,12 +34,12 @@ export default function reducer(state = defaultState, action = {}) { case actions.SETTING_SWITCH_TO_FORM: return { ...state, error: '', - source: 'form', + source: SettingSource.Form, form: action.form, }; case actions.SETTING_SWITCH_TO_JSON: return { ...state, error: '', - source: 'json', + source: SettingSource.JSON, json: action.json, }; default: return state; |