45 lines
751 B
TypeScript
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;
|
||
|
}
|
||
|
}
|
||
|
}
|