1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-06 11:25:16 +02:00

Created config global state. Reworked WeatherSettings and WeatherWidget to use new config state.

This commit is contained in:
unknown 2021-06-13 00:16:57 +02:00
parent a5504e6e80
commit d257fbf9a3
15 changed files with 214 additions and 88 deletions

View file

@ -0,0 +1,36 @@
import { ActionTypes, Action } from '../actions';
import { Config } from '../../interfaces';
export interface State {
loading: boolean;
config: Config[];
}
const initialState: State = {
loading: true,
config: []
}
const getConfig = (state: State, action: Action): State => {
return {
loading: false,
config: action.payload
}
}
const updateConfig = (state: State, action: Action): State => {
return {
...state,
config: action.payload
}
}
const configReducer = (state: State = initialState, action: Action) => {
switch(action.type) {
case ActionTypes.getConfig: return getConfig(state, action);
case ActionTypes.updateConfig: return updateConfig(state, action);
default: return state;
}
}
export default configReducer;