fabric8-planner
Version:
A planner front-end for Fabric8.
45 lines • 1.53 kB
JavaScript
import * as CommentActions from './../actions/comment.actions';
import { initialState } from './../states/comment.state';
export var CommentReducer = function (state, action) {
if (state === void 0) { state = initialState; }
switch (action.type) {
case CommentActions.GET_SUCCESS: {
return action.payload.slice();
}
case CommentActions.GET_ERROR: {
return state;
}
case CommentActions.ADD_SUCCESS: {
return [action.payload].concat(state);
}
case CommentActions.ADD_ERROR: {
return state;
}
case CommentActions.UPDATE_SUCCESS: {
var updatedComment_1 = action.payload;
var index = state.findIndex(function (c) { return c.id === updatedComment_1.id; });
if (index > -1) {
state[index] = action.payload;
}
return state.slice();
}
case CommentActions.UPDATE_ERROR: {
return state;
}
case CommentActions.DELETE_SUCCESS: {
var deletedComment_1 = action.payload;
var index = state.findIndex(function (c) { return c.id === deletedComment_1.id; });
if (index > -1) {
state.splice(index, 1);
}
return state.slice();
}
case CommentActions.DELETE_ERROR: {
return state;
}
default: {
return state;
}
}
};
//# sourceMappingURL=comment.reducer.js.map