import { NotificationModel } from './interfaces' import { NotificationAction, SHOW_NOTIFICATION, HIDE_NOTIFICATION } from './actions' export type NotificationState = NotificationModel[] const initialState: NotificationState = [] export const notificationReducer = (state = initialState, action: NotificationAction): NotificationState => { switch (action.type) { case SHOW_NOTIFICATION: { return [ ...state, { autoclose: action.autoclose, message: action.message, level: action.level, id: action.id, }, ] } case HIDE_NOTIFICATION: { return state.filter(n => n.id !== action.id) } default: { return state } } }