Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- PHOTO_DETAIL_FETCH,
- PHOTO_DETAIL_ERROR,
- PHOTO_DETAIL_LOADED
- } from '../actions/index';
- const defaultState = {
- "isLoading": false,
- "isError": false,
- "message": "",
- "photo": {},
- "comments": []
- }
- export default function photoDetail(state = defaultState, action){
- switch(action.type){
- case PHOTO_DETAIL_FETCH:
- return Object.assign({}, state, {isLoading: true});
- case PHOTO_DETAIL_LOADED:
- return Object.assign({}, state, {isLoading: false, isError: false, photo: action.detail.photo, comments: action.detail.comments});
- case PHOTO_DETAIL_ERROR:
- return Object.assign({}, state, {isLoading: false, isError: true, message: action.message});
- default:
- return state;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement