Skip to content

Instantly share code, notes, and snippets.

@yogieputra8
Created February 8, 2018 13:23
Show Gist options
  • Save yogieputra8/ebfef49009ecdfb61a85e5702ccd04a4 to your computer and use it in GitHub Desktop.
Save yogieputra8/ebfef49009ecdfb61a85e5702ccd04a4 to your computer and use it in GitHub Desktop.
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