client/src/reducers/utils.js
author ymh <ymh.work@gmail.com>
Fri, 30 Nov 2018 10:53:15 +0100
changeset 183 f8f3af9e5c83
parent 168 ea92f4fe783d
permissions -rw-r--r--
Change the settings to avoid using Session authentication for rest framework as it raise exceptions in case client and backend are on the same domain On the filter, adapt to take into account new version of django_filters

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