Guest User

Untitled

a guest
Feb 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import { combineReducers } from 'redux'
  2. import { PENDING, FULFILLED, REJECTED } from 'redux-promise-middleware'
  3. import {
  4. FETCH_DATA,
  5. FETCH_BANNERS
  6. } from '../actions/index'
  7.  
  8.  
  9.  
  10. export const data = (state = {
  11. items: '',
  12. }, action) => {
  13. switch (action.type){
  14. case `${FETCH_DATA}`:
  15. return {
  16. ...state,
  17. items: 'This is data from redux'
  18. }
  19.  
  20. default:
  21. return state
  22. }
  23. }
  24.  
  25.  
  26. export const banners = (state = {
  27. isFetching: false,
  28. items: []
  29. }, action) => {
  30. switch (action.type){
  31. case `${FETCH_BANNERS}_PENDING`:
  32. return {
  33. ...state,
  34. isFetching: true
  35. }
  36.  
  37. case `${FETCH_BANNERS}_FULFILLED`:
  38. return {
  39. ...state,
  40. isFetching: false,
  41. items: action.payload
  42. }
  43.  
  44. case `${FETCH_BANNERS}_REJECTED`:
  45. return {
  46. ...state
  47. }
  48.  
  49. default:
  50. return state
  51. }
  52. }
  53.  
  54.  
  55.  
  56.  
  57. const rootReducer = combineReducers({
  58. data,
  59. banners
  60. })
  61.  
  62. export default rootReducer
Add Comment
Please, Sign In to add comment