appNotification.ts 727 B

12345678910111213141516171819
  1. import { AppNotification, AppNotificationsState } from 'app/types/';
  2. import { Action, ActionTypes } from '../actions/appNotification';
  3. export const initialState: AppNotificationsState = {
  4. appNotifications: [] as AppNotification[],
  5. };
  6. export const appNotificationsReducer = (state = initialState, action: Action): AppNotificationsState => {
  7. switch (action.type) {
  8. case ActionTypes.AddAppNotification:
  9. return { ...state, appNotifications: state.appNotifications.concat([action.payload]) };
  10. case ActionTypes.ClearAppNotification:
  11. return {
  12. ...state,
  13. appNotifications: state.appNotifications.filter(appNotification => appNotification.id !== action.payload),
  14. };
  15. }
  16. return state;
  17. };