29 lines
987 B
JavaScript
29 lines
987 B
JavaScript
import { storeActions } from "@/constants/store-actions.js";
|
|
import { widgetNames } from "@/constants/widget-names.js";
|
|
import store from "@/store";
|
|
|
|
export function fetchCmsContentForPage(fmgPage) {
|
|
return store.dispatch(storeActions.GET_PAGE_DATA, { pageName: fmgPage }).then((response) => {
|
|
const pageDataFromCms = {
|
|
isCmsContentReady: false
|
|
};
|
|
|
|
response.data.Result.forEach((widget) => {
|
|
if (Object.values(widgetNames).includes(widget.Type)) {
|
|
// If we already have this widget, push it on the collection
|
|
if (widget.Type in pageDataFromCms) {
|
|
pageDataFromCms[widget.Type].push(widget.Model);
|
|
return;
|
|
}
|
|
|
|
pageDataFromCms[widget.Type] = [widget.Model];
|
|
}
|
|
});
|
|
|
|
// Our 'Page' is ready because we have data now
|
|
pageDataFromCms.isCmsContentReady = true;
|
|
|
|
return pageDataFromCms;
|
|
});
|
|
}
|
|
|