From a0882bbceb7ed71d56bf8557620449fbc3f19749 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 5 May 2019 08:03:29 +0900 Subject: Declare setting types --- src/settings/reducers/setting.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/settings/reducers') 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; -- cgit v1.2.3