member_webapp/@overflow/notification/store/detail/notification.reducer.ts

45 lines
751 B
TypeScript
Raw Normal View History

2018-04-06 11:02:18 +00:00
import {
Actions,
ActionType,
} from './notification.action';
import {
State,
initialState,
} from './notification.state';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.MarkAsRead: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.MarkAsReadSuccess: {
return {
...state,
error: null,
pending: false,
notification: action.payload,
};
}
case ActionType.MarkAsReadFailure: {
return {
...state,
error: action.payload,
pending: false,
notification: null,
};
}
default: {
return state;
}
}
}