Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import {
  2. PHOTO_DETAIL_FETCH,
  3. PHOTO_DETAIL_ERROR,
  4. PHOTO_DETAIL_LOADED
  5. } from '../actions/index';
  6.  
  7. const defaultState = {
  8. "isLoading": false,
  9. "isError": false,
  10. "message": "",
  11. "photo": {},
  12. "comments": []
  13. }
  14.  
  15. export default function photoDetail(state = defaultState, action){
  16. switch(action.type){
  17. case PHOTO_DETAIL_FETCH:
  18. return Object.assign({}, state, {isLoading: true});
  19. case PHOTO_DETAIL_LOADED:
  20. return Object.assign({}, state, {isLoading: false, isError: false, photo: action.detail.photo, comments: action.detail.comments});
  21. case PHOTO_DETAIL_ERROR:
  22. return Object.assign({}, state, {isLoading: false, isError: true, message: action.message});
  23. default:
  24. return state;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement