Add Redux and use it for state management

This commit is contained in:
riggraz
2019-09-11 18:30:59 +02:00
parent db4c1445ba
commit 8d9ab0f717
22 changed files with 656 additions and 246 deletions

View File

@@ -0,0 +1,34 @@
import IPost from '../interfaces/IPost';
const initialState: IPost = {
id: 0,
title: '',
description: null,
boardId: 0,
postStatusId: null,
userId: 0,
createdAt: '',
};
const postReducer = (
state = initialState,
action,
): IPost => {
switch (action.type) {
case 'CONVERT':
return {
id: action.post.id,
title: action.post.title,
description: action.post.description,
boardId: action.post.board_id,
postStatusId: action.post.post_status_id,
userId: action.post.user_id,
createdAt: action.post.created_at,
};
default:
return state;
}
}
export default postReducer;