@collectionspace/cspace-public-browser
Version:
CollectionSpace public browser
41 lines (40 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.get = exports.default = void 0;
var _immutable = _interopRequireDefault(require("immutable"));
var _actionCodes = require("../constants/actionCodes");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const setMedia = (state, action) => {
const {
csids,
altTexts,
title
} = action.payload;
const {
institutionId,
referenceValue
} = action.meta;
return state.setIn([referenceValue, 'media', institutionId], _immutable.default.fromJS({
csids,
altTexts,
title
}));
};
var _default = (state = _immutable.default.Map(), action) => {
switch (action.type) {
case _actionCodes.SET_MEDIA:
return setMedia(state, action);
default:
return state;
}
};
exports.default = _default;
const get = (state, referenceValue, institutionId) => {
if (typeof institutionId === 'undefined') {
return state.getIn([referenceValue, 'media']);
}
return state.getIn([referenceValue, 'media', institutionId]);
};
exports.get = get;