1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = exports.configureWithClientMainQuery = void 0;
|
9 |
|
10 | var _reactRedux = require("react-redux");
|
11 |
|
12 | var _lifecycle = _interopRequireDefault(require("recompose/lifecycle"));
|
13 |
|
14 | var _compose = _interopRequireDefault(require("recompose/compose"));
|
15 |
|
16 |
|
17 |
|
18 | var configuredFetchPageThunk;
|
19 |
|
20 | var configureWithClientMainQuery = function configureWithClientMainQuery(fetchPageThunk) {
|
21 | configuredFetchPageThunk = fetchPageThunk;
|
22 | };
|
23 |
|
24 | exports.configureWithClientMainQuery = configureWithClientMainQuery;
|
25 | var lifecycle = {
|
26 | componentDidMount: function componentDidMount() {
|
27 | if (!configuredFetchPageThunk) {
|
28 | throw Error('You must configure a fetchPageThunk with configureWithClientMainQuery');
|
29 | }
|
30 |
|
31 | var _this$props = this.props,
|
32 | dispatch = _this$props.dispatch,
|
33 | route = _this$props.route;
|
34 |
|
35 | if (route.mainQuery) {
|
36 | var urlParams = this.props.match.params;
|
37 | var _route$mainQuery = route.mainQuery,
|
38 | query = _route$mainQuery.query,
|
39 | mapUrlParams = _route$mainQuery.mapUrlParams,
|
40 | mapResp = _route$mainQuery.mapResp;
|
41 | dispatch(configuredFetchPageThunk({
|
42 | query: query,
|
43 | urlParams: urlParams,
|
44 | mapUrlParams: mapUrlParams,
|
45 | mapResp: mapResp
|
46 | }));
|
47 | }
|
48 | }
|
49 | };
|
50 | var withClientMainQuery = (0, _compose.default)((0, _reactRedux.connect)(function () {
|
51 | return {};
|
52 | }), (0, _lifecycle.default)(lifecycle));
|
53 | var _default = withClientMainQuery;
|
54 | exports.default = _default; |
\ | No newline at end of file |