@zohodesk/platform-middleware
Version:
Generalized Contract for the events from Marketplace App, In-App widgets, CRM-Plus and EFC
29 lines (25 loc) • 692 B
JavaScript
import { constants } from "../constants";
//TODO: runtimeWidgets - action creator - instance direct on uniqueID
//TODO: render widgets - action creator
export var fetchWidgetsSuccess = function fetchWidgetsSuccess(data) {
return {
type: 'FETCH_MY_WIDGETS_SUCCESS',
data: {
widgets: normalizeWidgets(data.widgets, 'id'),
uID: data.uID,
location: data.location
}
};
};
export var renderWidgets = function renderWidgets(widgets) {
return {
type: constants.RENDER_WIDGETS,
data: widgets
};
};
function normalizeWidgets(widgets, param) {
return widgets.reduce(function (obj, widget) {
obj[widget[param]] = widget;
return obj;
}, {});
}