'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getRelatedRecordBrowserRelatedCsid = undefined;

var _immutable = require('immutable');

var _immutable2 = _interopRequireDefault(_immutable);

var _recordBrowser = require('../actions/recordBrowser');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = function () {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _immutable2.default.Map();
  var action = arguments[1];

  switch (action.type) {
    case _recordBrowser.CLEAR_RELATED_RECORD_BROWSER_RELATED_CSID:
      return state.deleteIn(['relatedRecordBrowser', 'relatedCsid']);
    case _recordBrowser.SET_RELATED_RECORD_BROWSER_RELATED_CSID:
      return state.setIn(['relatedRecordBrowser', 'relatedCsid', action.meta.recordType], action.payload);
    default:
      return state;
  }
};

var getRelatedRecordBrowserRelatedCsid = exports.getRelatedRecordBrowserRelatedCsid = function getRelatedRecordBrowserRelatedCsid(state, recordType) {
  return state.getIn(['relatedRecordBrowser', 'relatedCsid', recordType]);
};