'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 = (state = _immutable2.default.Map(), action) => {
  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;
  }
};

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