Skip to content

Commit c1d3809

Browse files
committed
responding to review comments
1 parent 9799c7d commit c1d3809

24 files changed

+682
-482
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "react-app"
3+
}

package-lock.json

Lines changed: 336 additions & 234 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"array-sort": "^1.0.0",
67
"bootstrap": "^4.1.1",
78
"form-serialize": "^0.7.2",
89
"normalize.css": "^8.0.0",
@@ -16,7 +17,6 @@
1617
"react-router-dom": "^4.2.2",
1718
"react-scripts": "1.1.4",
1819
"redux": "^4.0.0",
19-
"redux-devtools-extension": "^2.13.2",
2020
"redux-logger": "^3.0.6",
2121
"redux-thunk": "^2.3.0",
2222
"serialize": "^0.1.3",

src/actions/categories.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import * as types from './types';
1+
import * as types from "./types";
22
import * as ReadableAPI from "../utils/api";
33

44
export const getCategories = () => {
55
return dispatch => {
6-
dispatch(requestCategories())
6+
dispatch(loadCategoriesRequest());
77
return ReadableAPI.getCategories().then(response => {
8-
dispatch(receiveCategories(response))});
9-
}
8+
dispatch(loadCategoriesSuccess(response));
9+
});
10+
};
1011
};
1112

12-
export const receiveCategories = categories => {
13+
export const loadCategoriesSuccess = categories => {
1314
return {
14-
type: types.RECEIVE_CATEGORIES,
15+
type: types.LOAD_CATEGORIES_SUCCESS,
1516
categories: categories
1617
};
1718
};
18-
export const requestCategories= () => {
19+
export const loadCategoriesRequest = () => {
1920
return {
20-
type: types.REQUEST_CATEGORIES
21-
}
22-
}
21+
type: types.LOAD_CATEGORIES_REQUEST
22+
};
23+
};

src/actions/comments.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,113 +3,113 @@ import * as ReadableAPI from "../utils/api";
33

44
export const getCommentsByPostId = id => {
55
return dispatch => {
6-
dispatch(requestCommentsByPostId());
6+
dispatch(commentsByPostIdRequest());
77
return ReadableAPI.getComments(id).then(response =>
8-
dispatch(receiveCommentsByPostId(response))
8+
dispatch(commentsByPostIdSuccess(response))
99
);
1010
};
1111
};
1212

1313
export const createComment = comment => {
1414
return dispatch => {
15-
dispatch(requestCreateComment());
15+
dispatch(createCommentRequest());
1616
return ReadableAPI.addComment(comment).then(response =>
17-
dispatch(receiveCreateComment(response))
17+
dispatch(createCommentSuccess(response))
1818
);
1919
};
2020
};
2121

2222
export const editComment = comment => {
2323
return dispatch => {
24-
dispatch(requestEditComment());
24+
dispatch(editCommentRequest());
2525
return ReadableAPI.editComment(comment).then(response =>
26-
dispatch(receiveEditComment(response))
26+
dispatch(editCommentSuccess(response))
2727
);
2828
};
2929
};
3030

3131
export const deleteComment = id => {
3232
return dispatch => {
33-
dispatch(requestDeleteComment());
33+
dispatch(deleteCommentRequest());
3434
return ReadableAPI.deleteComment(id).then(response =>
35-
dispatch(receiveDeleteComment(response))
35+
dispatch(deleteCommentSuccess(response))
3636
);
3737
};
3838
};
3939

4040
export const castVote = payload => {
4141
return dispatch => {
42-
dispatch(requestCommentVote());
42+
dispatch(commentVoteRequest());
4343
return ReadableAPI.voteComment(payload).then(response =>
44-
dispatch(receiveCommentVote(response))
44+
dispatch(commentVoteSuccess(response))
4545
);
4646
};
4747
};
4848

49-
export const receiveCommentsByPostId = comments => {
49+
export const commentsByPostIdSuccess = comments => {
5050
return {
51-
type: types.RECEIVE_COMMENTS_BY_POST_ID,
51+
type: types.LOAD_COMMENTS_BY_POST_ID_SUCCESS,
5252
comments: comments
5353
};
5454
};
55-
export const requestCommentsByPostId = () => {
55+
export const commentsByPostIdRequest = () => {
5656
return {
57-
type: types.REQUEST_COMMENTS_BY_POST_ID
57+
type: types.LOAD_COMMENTS_BY_POST_ID_REQUEST
5858
};
5959
};
60-
export const receiveCommentVote = comment => {
60+
export const commentVoteSuccess = comment => {
6161
return {
62-
type: types.RECEIVE_COMMENT_VOTE,
62+
type: types.COMMENT_VOTE_SUCCESS,
6363
comment: comment
6464
};
6565
};
66-
export const requestCommentVote = () => {
66+
export const commentVoteRequest = () => {
6767
return {
68-
type: types.REQUEST_COMMENT_VOTE
68+
type: types.COMMENT_VOTE_REQUEST
6969
};
7070
};
71-
export const receiveDeleteComment = comment => {
71+
export const deleteCommentSuccess = comment => {
7272
return {
73-
type: types.RECEIVE_DELETE_COMMENT,
73+
type: types.DELETE_COMMENT_SUCCESS,
7474
comment: comment
7575
};
7676
};
77-
export const requestDeleteComment = () => {
77+
export const deleteCommentRequest = () => {
7878
return {
79-
type: types.REQUEST_DELETE_COMMENT
79+
type: types.DELETE_COMMENT_REQUEST
8080
};
8181
};
8282

83-
export const receiveEditComment = comment => {
83+
export const editCommentSuccess = comment => {
8484
return {
85-
type: types.RECEIVE_EDIT_COMMENT,
85+
type: types.EDIT_COMMENT_SUCCESS,
8686
comment: comment
8787
};
8888
};
89-
export const requestEditComment = () => {
89+
export const editCommentRequest = () => {
9090
return {
91-
type: types.REQUEST_EDIT_COMMENT
91+
type: types.EDIT_COMMENT_REQUEST
9292
};
9393
};
94-
export const receiveCreateComment = comment => {
94+
export const createCommentSuccess = comment => {
9595
return {
96-
type: types.RECEIVE_CREATE_COMMENT,
96+
type: types.CREATE_COMMENT_SUCCESS,
9797
comment: comment
9898
};
9999
};
100-
export const requestCreateComment = () => {
100+
export const createCommentRequest = () => {
101101
return {
102-
type: types.REQUEST_CREATE_COMMENT
102+
type: types.CREATE_COMMENT_REQUEST
103103
};
104104
};
105-
export const receiveCommentById = comment => {
105+
export const commentByIdSuccess = comment => {
106106
return {
107-
type: types.RECEIVE_COMMENT_BY_ID,
107+
type: types.LOAD_COMMENT_BY_ID_SUCCESS,
108108
comment: comment
109109
};
110110
};
111-
export const requestCommentById = () => {
111+
export const commentByIdRequest = () => {
112112
return {
113-
type: types.REQUEST_COMMENT_BY_ID
113+
type: types.LOAD_COMMENT_BY_ID_REQUEST
114114
};
115115
};

src/actions/post.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@ import * as ReadableAPI from "../utils/api";
33

44
export const getPostById = id => {
55
return dispatch => {
6-
dispatch(requestPostById());
7-
return ReadableAPI.getPostById(id).then(response =>
8-
dispatch(receivePostById(response))
9-
);
6+
dispatch(loadPostByIdRequest());
7+
return ReadableAPI.getPostById(id).then(response => {
8+
if (response.error) {
9+
dispatch(loadPostByIdFailure(response));
10+
} else {
11+
dispatch(loadPostByIdSuccess(response));
12+
}
13+
});
1014
};
1115
};
12-
export const receivePostById = post => {
16+
export const loadPostByIdSuccess = post => {
1317
return {
14-
type: types.RECEIVE_POST_BY_ID,
18+
type: types.LOAD_POST_BY_ID_SUCCESS,
1519
post: post
1620
};
1721
};
18-
export const requestPostById = () => {
22+
export const loadPostByIdRequest = () => {
1923
return {
20-
type: types.REQUEST_POST_BY_ID
24+
type: types.LOAD_POST_BY_ID_REQUEST
25+
};
26+
};
27+
export const loadPostByIdFailure = error => {
28+
return {
29+
type: types.LOAD_POST_BY_ID_FAILURE,
30+
error: error
2131
};
2232
};

0 commit comments

Comments
 (0)