canape/frontend/js/reducers/notifications.js
Grégoire Delattre bcadc48d5a Launch prettier with the --fix option
They've changed their default settings, this changes a lot of stuff in
our code base.
2020-04-01 17:55:34 +02:00

19 lines
485 B
JavaScript

import { List, fromJS } from "immutable";
const defaultState = List();
const handlers = {
ADD_NOTIFICATION: (state, action) =>
state.push(
fromJS({
id: Math.random().toString(36).substring(7),
...action.payload,
})
),
REMOVE_NOTIFICATION: (state, action) =>
state.filter((e) => e.get("id") !== action.payload.id),
};
export default (state = defaultState, action) =>
handlers[action.type] ? handlers[action.type](state, action) : state;