@griddo/cx 1.73.28 → 1.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/services/distributors.js +25 -20
- package/src/utils/pages.js +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/cx",
|
|
3
3
|
"description": "Griddo SSG based on Gatsby",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.74.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"react-helmet": "^6.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@griddo/eslint-config-back": "^1.
|
|
68
|
+
"@griddo/eslint-config-back": "^1.74.0",
|
|
69
69
|
"eslint": "^7.5.0",
|
|
70
70
|
"eslint-plugin-node": "^11.1.0",
|
|
71
71
|
"eslint-plugin-react": "7.14.3",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "e88b4badd147dea446fe3d489b623837ab0e6f51"
|
|
101
101
|
}
|
|
@@ -10,29 +10,31 @@ class DistributorService {
|
|
|
10
10
|
mode,
|
|
11
11
|
fixed,
|
|
12
12
|
filter,
|
|
13
|
-
fullRelations = false
|
|
13
|
+
fullRelations = false,
|
|
14
14
|
} = data;
|
|
15
15
|
|
|
16
16
|
return mode === 'auto'
|
|
17
17
|
? {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
mode,
|
|
19
|
+
order,
|
|
20
|
+
source,
|
|
21
|
+
quantity,
|
|
22
|
+
filter,
|
|
23
|
+
fullRelations,
|
|
24
|
+
}
|
|
25
25
|
: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
mode,
|
|
27
|
+
fixed,
|
|
28
|
+
fullRelations,
|
|
29
|
+
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
static async fetchData({ page, component, cached }) {
|
|
33
33
|
const { data } = component;
|
|
34
34
|
if (!data) {
|
|
35
|
-
console.log(
|
|
35
|
+
console.log(
|
|
36
|
+
`======= ERROR: Página ${page.id} tiene un hasDistributorData pero no un elemento data con la configuración del distribuidor en el mismo nivel.`
|
|
37
|
+
);
|
|
36
38
|
return [];
|
|
37
39
|
}
|
|
38
40
|
const body = this.getBody(data);
|
|
@@ -45,24 +47,27 @@ class DistributorService {
|
|
|
45
47
|
const { template } = page;
|
|
46
48
|
|
|
47
49
|
const checkDistributors = async (template, level = 1) => {
|
|
48
|
-
if (!template || typeof
|
|
49
|
-
if (!JSON.stringify(template).includes('"hasDistributorData":true'))
|
|
50
|
+
if (!template || typeof template !== 'object') return;
|
|
51
|
+
if (!JSON.stringify(template).includes('"hasDistributorData":true'))
|
|
52
|
+
return;
|
|
50
53
|
for (let key in template) {
|
|
51
|
-
if (key === 'queriedItems') continue;
|
|
54
|
+
if (key === 'queriedItems' || key === 'queriedData') continue;
|
|
52
55
|
const component = template[key];
|
|
53
|
-
if (!component || typeof
|
|
56
|
+
if (!component || typeof component !== 'object') continue;
|
|
54
57
|
if (component.hasDistributorData) {
|
|
55
58
|
component.queriedItems = await this.fetchData({
|
|
56
59
|
page,
|
|
57
60
|
component,
|
|
58
|
-
cached
|
|
61
|
+
cached,
|
|
59
62
|
});
|
|
63
|
+
component.queriedData = component.queriedItems;
|
|
60
64
|
}
|
|
65
|
+
|
|
61
66
|
await checkDistributors(component, level + 1);
|
|
62
67
|
}
|
|
63
68
|
};
|
|
64
69
|
|
|
65
|
-
const getDistributors = async
|
|
70
|
+
const getDistributors = async template => {
|
|
66
71
|
await checkDistributors([template]); // ==> En array para que también revise la propia template como objeto.
|
|
67
72
|
return template;
|
|
68
73
|
};
|
|
@@ -76,4 +81,4 @@ class DistributorService {
|
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
exports.default = DistributorService;
|
|
84
|
+
exports.default = DistributorService;
|