member_webapp/@overflow/notification/store/detail/notification.reducer.ts
crusader d59d9379f9 ing
2018-05-24 15:44:13 +09:00

45 lines
751 B
TypeScript

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;
}
}
}