diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-05 08:03:29 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-06 22:17:18 +0900 |
commit | a0882bbceb7ed71d56bf8557620449fbc3f19749 (patch) | |
tree | f2087d44f21dd68fc3584f62cfb9b62ae58bab2b /src/settings/reducers | |
parent | d01db82c0dca352de2d7644c383d388fc3ec0366 (diff) |
Declare setting types
Diffstat (limited to 'src/settings/reducers')
-rw-r--r-- | src/settings/reducers/setting.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/settings/reducers/setting.ts b/src/settings/reducers/setting.ts index 47c21bf..c4a21c7 100644 --- a/src/settings/reducers/setting.ts +++ b/src/settings/reducers/setting.ts @@ -1,23 +1,25 @@ import * as actions from '../actions'; +import { + JSONSettings, FormSettings, SettingSource, +} from '../../shared/SettingData'; -interface State { - source: string; - json: string; - form: any; +export interface State { + source: SettingSource; + json?: JSONSettings; + form?: FormSettings; error: string; } const defaultState: State = { - source: '', - json: '', - form: null, + source: SettingSource.JSON, + json: JSONSettings.valueOf(''), error: '', }; export default function reducer( state = defaultState, action: actions.SettingAction, -) { +): State { switch (action.type) { case actions.SETTING_SET_SETTINGS: return { ...state, @@ -32,12 +34,12 @@ export default function reducer( 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; |