"use strict";

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

var _immutable = _interopRequireDefault(require("immutable"));

var _actionCodes = require("../constants/actionCodes");

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

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

  switch (action.type) {
    case _actionCodes.CLEAR_RELATED_RECORD_BROWSER_RELATED_CSID:
      return state.deleteIn(['relatedRecordBrowser', 'relatedCsid']);

    case _actionCodes.SET_RELATED_RECORD_BROWSER_RELATED_CSID:
      return state.setIn(['relatedRecordBrowser', 'relatedCsid', action.meta.recordType], action.payload);

    default:
      return state;
  }
};

exports.default = _default;

const getRelatedRecordBrowserRelatedCsid = (state, recordType) => state.getIn(['relatedRecordBrowser', 'relatedCsid', recordType]);

exports.getRelatedRecordBrowserRelatedCsid = getRelatedRecordBrowserRelatedCsid;