node-go/packages/server/play-node-go/src/reducers/stateReducer.js

35 lines
752 B
JavaScript
Raw Normal View History

// @flow
import { initState } from './init/stateReducer.init';
import { authReducer } from './auth/stateReducer.auth';
2020-01-18 00:32:40 +00:00
import { indexReducer } from './index/stateReducer.index';
export type state = {
user: {},
errors: {}
}
export type action = {
type: string,
message: ?string,
body: {}
}
export const stateReducer = (state: state, action: action): state => {
const errorStrippedState = stripErrors({...state});
switch (action.type) {
case 'INIT': return initState();
2020-01-18 00:32:40 +00:00
case 'INDEX':
return indexReducer(errorStrippedState, action);
2020-01-17 20:21:43 +00:00
case 'AUTH':
return authReducer(errorStrippedState, action);
default: return state;
}
}
function stripErrors(state: state): state {
return {...state, errors: {}}
}