"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = _default;

var _ramda = require("ramda");

var setJob = function setJob(job, state) {
  return (0, _ramda.assoc)(job.jobId, job, state);
};

var removeJob = function removeJob(jobId, state) {
  return (0, _ramda.dissoc)(jobId, state);
};

var setOutdated = function setOutdated(jobId, state) {
  return (0, _ramda.assocPath)([jobId, 'outdated'], true, state);
};

function _default() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var action = arguments.length > 1 ? arguments[1] : undefined;

  switch (action.type) {
    case 'ADD_CALLBACK_JOB':
      return setJob(action.payload, state);

    case 'REMOVE_CALLBACK_JOB':
      return removeJob(action.payload.jobId, state);

    case 'CALLBACK_JOB_OUTDATED':
      return setOutdated(action.payload.jobId, state);

    default:
      return state;
  }
}