2017-06-26 22:27:55 +00:00
|
|
|
// @flow
|
2017-04-14 06:25:01 +00:00
|
|
|
import {
|
|
|
|
CONFIG_LANGUAGE_CHANGE,
|
2017-05-23 23:06:01 +00:00
|
|
|
CONFIG_NODE_CHANGE
|
|
|
|
} from 'actions/config';
|
|
|
|
import {languages, nodeList} from '../config/data';
|
2017-04-14 06:25:01 +00:00
|
|
|
|
2017-06-26 22:27:55 +00:00
|
|
|
export type State = {
|
|
|
|
// FIXME
|
|
|
|
languageSelection: string,
|
|
|
|
nodeSelection: string
|
|
|
|
}
|
|
|
|
|
2017-04-14 06:25:01 +00:00
|
|
|
const initialState = {
|
2017-05-23 23:06:01 +00:00
|
|
|
languageSelection: languages[0],
|
|
|
|
nodeSelection: nodeList[0]
|
2017-04-14 06:25:01 +00:00
|
|
|
}
|
|
|
|
|
2017-06-26 22:27:55 +00:00
|
|
|
export function config(state: State = initialState, action): State {
|
2017-04-14 06:25:01 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case CONFIG_LANGUAGE_CHANGE: {
|
|
|
|
return {
|
|
|
|
...state,
|
2017-05-23 23:06:01 +00:00
|
|
|
languageSelection: action.value
|
2017-04-14 06:25:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case CONFIG_NODE_CHANGE: {
|
|
|
|
return {
|
|
|
|
...state,
|
2017-05-23 23:06:01 +00:00
|
|
|
nodeSelection: action.value
|
2017-04-14 06:25:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|