client/src/reducers/utils.js
author ymh <ymh.work@gmail.com>
Mon, 26 Nov 2018 13:57:30 +0100
changeset 178 89d8432aad9f
parent 168 ea92f4fe783d
permissions -rw-r--r--
Add a IRINOTES_CONFIG_BASE to allow giving a config file location

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;
  }
}