diff -r 1f340f3597a8 -r ea92f4fe783d client/src/reducers/utils.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/reducers/utils.js Mon Oct 08 18:35:47 2018 +0200 @@ -0,0 +1,18 @@ +import * as R from 'ramda'; +import { ActionEnum } from '../constants'; + +export const getId = R.prop('_id'); +export const idEq = R.propEq('_id'); +export const setAction = actionEnum => R.flip(R.merge)({action: actionEnum}) + +export const getNewAction = action => { + switch (action) { + case ActionEnum.CREATED: + return ActionEnum.CREATED; + case ActionEnum.DELETED: // should not happen, but... + return ActionEnum.DELETED; + default: + return ActionEnum.UPDATED; + } +} +