UNPKG

@zohodesk/platform-middleware

Version:

Generalized Contract for the events from Marketplace App, In-App widgets, CRM-Plus and EFC

43 lines (38 loc) 1.03 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); //TODO: runtimeWidgets - action creator - instance direct on uniqueID //TODO: render widgets - action creator var fetchWidgetsSuccess = exports.fetchWidgetsSuccess = function fetchWidgetsSuccess(data) { return { type: 'FETCH_MY_WIDGETS_SUCCESS', data: { widgets: normalizeWidgets(data.widgets, 'id'), uID: data.uID, location: data.location } }; }; var renderWidgetsAction = exports.renderWidgetsAction = function renderWidgetsAction(widgets) { return { type: 'RENDER_WIDGETS_NEW', data: widgets }; }; // export const fetchNextWidgetsSuccess = (dataObj) => { // return { // type: 'FETCH_MY_NEXT_WIDGETS_SUCCESS', // data: { // widgets: normalizeWidgets(dataObj.widgets, 'id'), // location, // uID // } // } // } function normalizeWidgets(widgets, param) { return widgets.reduce(function (obj, widget) { obj[widget[param]] = widget; return obj; }, {}); }