mirror of
https://github.com/xodio/xod.git
synced 2026-03-25 18:16:55 +01:00
25 lines
584 B
JavaScript
25 lines
584 B
JavaScript
import R from 'ramda';
|
|
import { ERROR_ADD, ERROR_DELETE } from '../actionTypes';
|
|
import { getNewId } from '../selectors/errors';
|
|
|
|
export const errorsReducer = (errors = {}, action) => {
|
|
switch (action.type) {
|
|
case ERROR_ADD: {
|
|
const newId = getNewId(errors);
|
|
return R.assoc(
|
|
newId,
|
|
{
|
|
id: newId,
|
|
timestamp: action.meta.timestamp,
|
|
payload: action.payload,
|
|
},
|
|
errors
|
|
);
|
|
}
|
|
case ERROR_DELETE:
|
|
return R.omit([action.payload.id.toString()], errors);
|
|
default:
|
|
return errors;
|
|
}
|
|
};
|