New comments can be created

This commit is contained in:
riggraz
2019-09-18 13:40:00 +02:00
parent ecfdc54100
commit 7701c8f5e6
12 changed files with 267 additions and 18 deletions

View File

@@ -1,22 +1,33 @@
import {
COMMENT_REQUEST_SUCCESS,
} from '../actions/requestComment';
import {
HandleCommentRepliesType,
TOGGLE_COMMENT_REPLY,
SET_COMMENT_REPLY_BODY,
} from '../actions/handleCommentReplies';
import {
COMMENT_SUBMIT_START,
COMMENT_SUBMIT_SUCCESS,
COMMENT_SUBMIT_FAILURE,
} from '../actions/submitComment';
export interface CommentRepliesState {
commentId: number;
isOpen: boolean;
body: string;
isSubmitting: boolean;
error: string;
}
const initialState: CommentRepliesState = {
commentId: undefined,
isOpen: false,
body: '',
isSubmitting: false,
error: '',
}
const commentRepliesReducer = (
@@ -42,6 +53,27 @@ const commentRepliesReducer = (
body: action.body,
};
case COMMENT_SUBMIT_START:
return {
...state,
isSubmitting: true,
};
case COMMENT_SUBMIT_SUCCESS:
return {
...state,
isOpen: false,
body: '',
isSubmitting: false,
error: '',
};
case COMMENT_SUBMIT_FAILURE:
return {
...state,
error: action.error,
};
default:
return state;
}