Files
astuto/app/javascript/reducers/commentReducer.ts

35 lines
754 B
TypeScript
Raw Normal View History

import {
2019-09-26 16:03:41 +02:00
CommentRequestSuccessAction,
COMMENT_REQUEST_SUCCESS,
} from '../actions/requestComment';
import IComment from '../interfaces/IComment';
const initialState: IComment = {
id: 0,
body: '',
2019-09-17 17:04:19 +02:00
parentId: null,
userFullName: '<Unknown user>',
updatedAt: undefined,
};
const commentReducer = (
state = initialState,
2019-09-26 16:03:41 +02:00
action: CommentRequestSuccessAction,
): IComment => {
switch (action.type) {
case COMMENT_REQUEST_SUCCESS:
return {
id: action.comment.id,
body: action.comment.body,
2019-09-17 17:04:19 +02:00
parentId: action.comment.parent_id,
userFullName: action.comment.user_full_name,
updatedAt: action.comment.updated_at,
};
default:
return state;
}
}
export default commentReducer;