client/src/reducers/utils.js
author ymh <ymh.work@gmail.com>
Tue, 29 Mar 2022 11:23:56 +0200
changeset 211 244a90638e80
parent 168 ea92f4fe783d
permissions -rw-r--r--
Added tag 0.2.3 for changeset 3de92ddba2de

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