Created
February 8, 2018 13:23
-
-
Save yogieputra8/ebfef49009ecdfb61a85e5702ccd04a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux' | |
import { PENDING, FULFILLED, REJECTED } from 'redux-promise-middleware' | |
import { | |
FETCH_DATA, | |
FETCH_BANNERS, | |
FETCH_DESTINATION | |
} from '../actions/index' | |
export const data = (state = { | |
items: '', | |
}, action) => { | |
switch (action.type){ | |
case `${FETCH_DATA}`: | |
return { | |
...state, | |
items: 'This is data from redux' | |
} | |
default: | |
return state | |
} | |
} | |
export const destinations = (state = { | |
isFetching: false, | |
items: [] | |
}, action) => { | |
switch (action.type){ | |
case `${FETCH_DESTINATION}_PENDING`: | |
return { | |
...state, | |
isFetching: true | |
} | |
case `${FETCH_DESTINATION}_FULFILLED`: | |
console.log(action.payload) | |
return { | |
...state, | |
isFetching: false, | |
items: action.payload | |
} | |
case `${FETCH_DESTINATION}_REJECTED`: | |
return { | |
...state | |
} | |
default: | |
return state | |
} | |
} | |
export const banners = (state = { | |
isFetching: false, | |
items: [] | |
}, action) => { | |
switch (action.type){ | |
case `${FETCH_BANNERS}_PENDING`: | |
return { | |
...state, | |
isFetching: true | |
} | |
case `${FETCH_BANNERS}_FULFILLED`: | |
console.log(action.payload) | |
return { | |
...state, | |
isFetching: false, | |
items: action.payload | |
} | |
case `${FETCH_BANNERS}_REJECTED`: | |
return { | |
...state | |
} | |
default: | |
return state | |
} | |
} | |
const rootReducer = combineReducers({ | |
data, | |
banners, | |
destinations | |
}) | |
export default rootReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment