Added actions and reducer for globalActions

This commit is contained in:
Philip Dimitratos 2017-12-29 14:18:41 -08:00
Родитель a71203f7e9
Коммит b2d2fa33c1
2 изменённых файлов: 42 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,27 @@
import { reduxBackedPromise } from './actionHelpers'
export const TRY_GET_GLOBAL_ACTIONS = 'TRY_GET_GLOBAL_ACTIONS'
export const GET_GLOBAL_ACTIONS_SUCCESS = 'GET_GLOBAL_ACTIONS_SUCCESS'
export const GET_GLOBAL_ACTIONS_FAILURE = 'GET_GLOBAL_ACTIONS_FAILURE'
export const fetchGlobalActions = () => reduxBackedPromise(
['globalActions/'],
getGlobalActionsActionSet
)
export const getGlobalActionsActionSet = ({
try: () => ({
type: TRY_GET_GLOBAL_ACTIONS
}),
succeed: (globalActions) => ({
type: GET_GLOBAL_ACTIONS_SUCCESS,
globalActions
}),
fail: (failureReason) => ({
type: GET_GLOBAL_ACTIONS_FAILURE,
failureReason
})
})

Просмотреть файл

@ -0,0 +1,15 @@
import * as globalActionActions from '../actions/globalActionActions'
import { mergeToStateById } from './reducerHelpers'
const defaultGlobalActionCollection = {}
export const records = (state = defaultGlobalActionCollection, action) => {
switch(action.type){
case globalActionActions.GET_GLOBAL_ACTIONS_SUCCESS:
return mergeToStateById(state, action.globalActions)
default:
return state
}
}
export default records