Restructure redux code (#109)

* Restructure redux code

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
mrdrogdrog 2020-05-31 22:51:36 +02:00 committed by GitHub
parent db5bec7000
commit 570c45017c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 214 additions and 231 deletions

View file

@ -1,7 +1,8 @@
import { Reducer } from 'redux'
import { BackendConfigActions, BackendConfigState, SET_BACKEND_CONFIG_ACTION_TYPE } from './types'
import { BackendConfig } from '../../api/backend-config/types'
import { BackendConfigActions, BackendConfigActionType, SetBackendConfigAction } from './types'
export const initialState: BackendConfigState = {
export const initialState: BackendConfig = {
allowAnonymous: true,
authProviders: {
facebook: false,
@ -33,10 +34,10 @@ export const initialState: BackendConfigState = {
}
}
export const BackendConfigReducer: Reducer<BackendConfigState, BackendConfigActions> = (state: BackendConfigState = initialState, action: BackendConfigActions) => {
export const BackendConfigReducer: Reducer<(BackendConfig), BackendConfigActions> = (state: (BackendConfig) = initialState, action: BackendConfigActions) => {
switch (action.type) {
case SET_BACKEND_CONFIG_ACTION_TYPE:
return action.payload.state
case BackendConfigActionType.SET_BACKEND_CONFIG:
return (action as SetBackendConfigAction).state
default:
return state
}