mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
Add basic version of Comments component
This commit is contained in:
32
app/javascript/reducers/commentReducer.ts
Normal file
32
app/javascript/reducers/commentReducer.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
COMMENT_REQUEST_SUCCESS,
|
||||
} from '../actions/requestComment';
|
||||
|
||||
import IComment from '../interfaces/IComment';
|
||||
|
||||
const initialState: IComment = {
|
||||
id: 0,
|
||||
body: '',
|
||||
userFullName: '',
|
||||
updatedAt: '',
|
||||
};
|
||||
|
||||
const commentReducer = (
|
||||
state = initialState,
|
||||
action,
|
||||
): IComment => {
|
||||
switch (action.type) {
|
||||
case COMMENT_REQUEST_SUCCESS:
|
||||
return {
|
||||
id: action.comment.id,
|
||||
body: action.comment.body,
|
||||
userFullName: action.comment.user_full_name,
|
||||
updatedAt: action.comment.updated_at,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default commentReducer;
|
||||
Reference in New Issue
Block a user