* Import missing action types for logout * Correctly destructure logout response from doFetchWithResponse * Return to SelectServer upon logout * Add todo regarding clearing clientConfig upon logout
34 lines
785 B
JavaScript
34 lines
785 B
JavaScript
import {PostsTypes, LogoutTypes} from 'constants';
|
|
const types = {...PostsTypes, ...LogoutTypes};
|
|
|
|
export const initState = {
|
|
status: 'not fetched',
|
|
error: null,
|
|
data: {}
|
|
};
|
|
|
|
export default function reducePosts(state = initState, action) {
|
|
switch (action.type) {
|
|
|
|
case types.FETCH_POSTS_REQUEST:
|
|
return {...state,
|
|
status: 'fetching',
|
|
error: null
|
|
};
|
|
case types.FETCH_POSTS_SUCCESS:
|
|
return {...state,
|
|
status: 'fetched',
|
|
data: action.data.posts
|
|
};
|
|
case types.FETCH_POSTS_FAILURE:
|
|
return {...state,
|
|
status: 'failed',
|
|
error: action.error
|
|
};
|
|
|
|
case types.LOGOUT_SUCCESS:
|
|
return initState;
|
|
default:
|
|
return state;
|
|
}
|
|
}
|