mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
32 lines
611 B
TypeScript
32 lines
611 B
TypeScript
|
|
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;
|