'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.simInitialState = undefined;
exports.default = simulationsReducer;
var _projects = require('../actions/projects');
var Actions = _interopRequireWildcard(_projects);
function _interopRequireWildcard(obj) { Eif (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var simInitialState = exports.simInitialState = {
mapById: {}
};
function simulationsReducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : simInitialState;
var action = arguments[1];
switch (action.type) {
case Actions.REMOVE_SIMULATION:
{
var mapById = Object.assign({}, state.mapById);
delete mapById[action.simulation._id];
return Object.assign({}, state, { mapById: mapById });
}
case Actions.UPDATE_SIMULATION:
{
var _mapById = Object.assign({}, state.mapById);
_mapById[action.simulation._id] = action.simulation;
return Object.assign({}, state, { mapById: _mapById });
}
case Actions.UPDATE_PROJECT_SIMULATIONS:
{
var _mapById2 = Object.assign({}, state.mapById);
action.simulations.forEach(function (simulation) {
_mapById2[simulation._id] = simulation;
});
return Object.assign({}, state, { mapById: _mapById2 });
}
default:
return state;
}
}
|