@brizy/media-gallery
Version:
55 lines (54 loc) • 2.56 kB
JavaScript
import React, { Suspense, useMemo } from "react";
import { Provider } from "react-redux";
import { configureStore } from "./redux/store";
import { LoadingPage } from "./components/miscellaneous/LoadingPage";
import { Translation } from "./locale/Translation";
import { contextFromRecord } from "./utils/contextFromRecord";
import { TranslationProvider } from "@brizy/ui/lib/utils/localization/TranslationProvider";
import { Notification } from "@brizy/ui/lib/Notification";
import { always } from "ramda";
import { Pages } from "./pages/containers";
import { GlobalNotificationsContainer } from "./containers/GlobalNotifications";
import { ConfigProvider } from "@brizy/ui/lib/ConfigProvider";
import { AlphaConfigProvider } from "@brizy/ui/lib/AlphaConfigProvider";
import { AlphaStyleProvider } from "@brizy/ui/lib/AlphaStyleProvider";
export var App = function(param) {
var config = param.config;
var context = useMemo(function() {
return contextFromRecord(config);
}, [
config
]);
if (!context || context.__type === "error") {
var message = (context === null || context === void 0 ? void 0 : context.message) ? "".concat(context === null || context === void 0 ? void 0 : context.message, " was not provided") : "Error you provided wrong config as props";
console.error(message);
return /*#__PURE__*/ React.createElement(Notification, {
position: "bottomCenter",
onClose: always,
offsetY: "88px",
notifications: [
{
id: message,
type: "error",
text: message,
closable: false
}
]
});
}
var store = configureStore(context);
var isRTL = config.isRTL;
return /*#__PURE__*/ React.createElement(Provider, {
store: store
}, /*#__PURE__*/ React.createElement(Translation, null, /*#__PURE__*/ React.createElement(TranslationProvider, {
locale: context.locale
}, /*#__PURE__*/ React.createElement(Suspense, {
fallback: /*#__PURE__*/ React.createElement(LoadingPage, null)
}, /*#__PURE__*/ React.createElement(AlphaStyleProvider, {
container: window.parent.document.head
}, /*#__PURE__*/ React.createElement(AlphaConfigProvider, {
isRTL: isRTL
}, /*#__PURE__*/ React.createElement(ConfigProvider, {
isRTL: isRTL
}, /*#__PURE__*/ React.createElement(Pages, null), /*#__PURE__*/ React.createElement(GlobalNotificationsContainer, null))))))));
};