mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add Likes in Post component
This commit is contained in:
@@ -15,6 +15,18 @@ import {
|
||||
CHANGE_POST_STATUS_SUCCESS,
|
||||
} from '../actions/changePostStatus';
|
||||
|
||||
import {
|
||||
LikesRequestActionTypes,
|
||||
LIKES_REQUEST_START,
|
||||
LIKES_REQUEST_SUCCESS,
|
||||
LIKES_REQUEST_FAILURE,
|
||||
} from '../actions/requestLikes';
|
||||
|
||||
import {
|
||||
LikeActionTypes,
|
||||
LIKE_SUBMIT_SUCCESS,
|
||||
} from '../actions/submitLike';
|
||||
|
||||
import {
|
||||
CommentsRequestActionTypes,
|
||||
COMMENTS_REQUEST_START,
|
||||
@@ -36,8 +48,10 @@ import {
|
||||
} from '../actions/submitComment';
|
||||
|
||||
import postReducer from './postReducer';
|
||||
import likesReducer from './likesReducer';
|
||||
import commentsReducer from './commentsReducer';
|
||||
|
||||
import { LikesState } from './likesReducer';
|
||||
import { CommentsState } from './commentsReducer';
|
||||
|
||||
import IPost from '../interfaces/IPost';
|
||||
@@ -46,6 +60,7 @@ interface CurrentPostState {
|
||||
item: IPost;
|
||||
isLoading: boolean;
|
||||
error: string;
|
||||
likes: LikesState;
|
||||
comments: CommentsState;
|
||||
}
|
||||
|
||||
@@ -53,6 +68,7 @@ const initialState: CurrentPostState = {
|
||||
item: postReducer(undefined, {} as PostRequestActionTypes),
|
||||
isLoading: false,
|
||||
error: '',
|
||||
likes: likesReducer(undefined, {} as LikesRequestActionTypes),
|
||||
comments: commentsReducer(undefined, {} as CommentsRequestActionTypes),
|
||||
};
|
||||
|
||||
@@ -62,6 +78,8 @@ const currentPostReducer = (
|
||||
PostRequestActionTypes |
|
||||
ChangePostBoardSuccessAction |
|
||||
ChangePostStatusSuccessAction |
|
||||
LikesRequestActionTypes |
|
||||
LikeActionTypes |
|
||||
CommentsRequestActionTypes |
|
||||
HandleCommentRepliesType |
|
||||
CommentSubmitActionTypes
|
||||
@@ -95,6 +113,15 @@ const currentPostReducer = (
|
||||
item: postReducer(state.item, action),
|
||||
};
|
||||
|
||||
case LIKES_REQUEST_START:
|
||||
case LIKES_REQUEST_SUCCESS:
|
||||
case LIKES_REQUEST_FAILURE:
|
||||
case LIKE_SUBMIT_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
likes: likesReducer(state.likes, action),
|
||||
};
|
||||
|
||||
case COMMENTS_REQUEST_START:
|
||||
case COMMENTS_REQUEST_SUCCESS:
|
||||
case COMMENTS_REQUEST_FAILURE:
|
||||
|
||||
Reference in New Issue
Block a user