1 | "use strict";
|
2 | var __importStar = (this && this.__importStar) || function (mod) {
|
3 | if (mod && mod.__esModule) return mod;
|
4 | var result = {};
|
5 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
6 | result["default"] = mod;
|
7 | return result;
|
8 | };
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | const React = __importStar(require("react"));
|
11 | const datalayer_libs_1 = require("./datalayer-libs");
|
12 |
|
13 | const DataLayerContext = React.createContext({});
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | const AttachDataLayer = (props) => {
|
23 | return React.createElement(DataLayerContext.Provider, { value: props.apolloClient }, props.children);
|
24 | };
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | function withDataLayer(Component) {
|
41 | return function WrapperComponent(props) {
|
42 | return (React.createElement(DataLayerContext.Consumer, null, value => {
|
43 | const entryListQuery = (entryId, dictKey) => datalayer_libs_1.getEntryListQuery(entryId, dictKey, {});
|
44 | return React.createElement(Component, Object.assign({}, props, { apolloClient: value, getEntryListQuery: entryListQuery }));
|
45 | }));
|
46 | };
|
47 | }
|
48 | exports.withDataLayer = withDataLayer;
|
49 | exports.default = AttachDataLayer;
|
50 |
|
\ | No newline at end of file |