Files
coopgo/node_modules/redux-notifications/src/reducer.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

19 lines
489 B
JavaScript

import { NOTIF_SEND, NOTIF_DISMISS, NOTIF_CLEAR } from './actions';
export default function notifs(domain = [], action) {
if (!action || !action.type) return domain;
switch (action.type) {
case NOTIF_SEND:
return [action.payload, ...domain.filter(({ id }) => id !== action.payload.id)];
case NOTIF_DISMISS:
return domain.filter(notif =>
notif.id !== action.payload
);
case NOTIF_CLEAR:
return [];
default:
return domain;
}
}