@q2devel/q2-core 1.0.45 → 1.0.47
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/dist/api/getTerms.js
CHANGED
|
@@ -7,8 +7,7 @@ export const getTerms = async (ctx, { categoryId, include = [
|
|
|
7
7
|
'field_icon.field_media_image',
|
|
8
8
|
'field_image',
|
|
9
9
|
'field_image.field_media_image',
|
|
10
|
-
], sortField
|
|
11
|
-
mapFn, }) => {
|
|
10
|
+
], sortField, mapFn, }) => {
|
|
12
11
|
const cacheKey = ['terms', ctx.locale, ...(categoryId ?? []), ...(include ?? [])].join(':');
|
|
13
12
|
const cached = await ctx.getCache?.(cacheKey);
|
|
14
13
|
if (cached)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,2BAA2B,CAAA;AAkIxE,wBAAgB,UAAU,CAAC,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAexF;AAED,wBAAgB,cAAc,CAAC,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAKxF"}
|
|
@@ -39,8 +39,12 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
39
39
|
const variationImages = variationProduct.field_image;
|
|
40
40
|
const discountPercent = getDiscountPercent(variationProduct.price, variationProduct.list_price);
|
|
41
41
|
const badges = [
|
|
42
|
-
...(variationProduct.field_news
|
|
43
|
-
|
|
42
|
+
...(variationProduct.field_news
|
|
43
|
+
? [{ text: 'Novinka', color: 'bg-green-100 text-green-800' }]
|
|
44
|
+
: []),
|
|
45
|
+
...(variationProduct.field_aftersale
|
|
46
|
+
? [{ text: 'Doprodej', color: 'bg-red-100 text-red-800' }]
|
|
47
|
+
: []),
|
|
44
48
|
];
|
|
45
49
|
return {
|
|
46
50
|
variation_id: variationProduct.drupal_internal__variation_id,
|
|
@@ -50,7 +54,9 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
50
54
|
sku: variationProduct.sku,
|
|
51
55
|
ean: variationProduct.field_ean,
|
|
52
56
|
description: defaultProduct.field_description?.processed ?? '',
|
|
53
|
-
price: variationProduct?.list_price?.number
|
|
57
|
+
price: variationProduct?.list_price?.number
|
|
58
|
+
? variationProduct.list_price.number
|
|
59
|
+
: variationProduct.price?.number ?? 0,
|
|
54
60
|
discountPercent,
|
|
55
61
|
product_id: defaultProduct.drupal_internal__product_id,
|
|
56
62
|
product_name: defaultProduct.title,
|
|
@@ -68,25 +74,48 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
68
74
|
field_shipping: defaultProduct.field_shipping ?? [],
|
|
69
75
|
...(variationProduct.packaging ? { packaging: variationProduct.packaging } : {}),
|
|
70
76
|
...(variationProduct.country ? { country: variationProduct.country } : {}),
|
|
71
|
-
...(variationProduct.weight &&
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
...(variationProduct.weight &&
|
|
78
|
+
variationProduct.weight.number &&
|
|
79
|
+
variationProduct.weight.unit
|
|
80
|
+
? {
|
|
81
|
+
weight: `${Number(variationProduct.weight.number).toFixed(2).toString()} ${variationProduct.weight.unit}`,
|
|
82
|
+
}
|
|
83
|
+
: {}),
|
|
84
|
+
...(variationProduct.weight && variationProduct.weight.unit
|
|
85
|
+
? { volume_unit: variationProduct.weight.unit }
|
|
86
|
+
: {}),
|
|
87
|
+
...(variationProduct.weight && variationProduct.weight.number
|
|
88
|
+
? { volume_number: variationProduct.weight.number }
|
|
89
|
+
: {}),
|
|
90
|
+
...(variationProduct.field_discount
|
|
91
|
+
? { field_discount: variationProduct.field_discount }
|
|
92
|
+
: {}),
|
|
93
|
+
...(variationProduct.field_composition
|
|
94
|
+
? { field_composition: variationProduct.field_composition }
|
|
95
|
+
: {}),
|
|
96
|
+
...(variationProduct.field_nutritional_info
|
|
97
|
+
? { field_nutritional_info: variationProduct.field_nutritional_info }
|
|
98
|
+
: {}),
|
|
99
|
+
...(variationProduct.field_species
|
|
100
|
+
? { field_species: variationProduct.field_species }
|
|
101
|
+
: {}),
|
|
78
102
|
...(variationProduct.field_volume ? { field_volume: variationProduct.field_volume } : {}),
|
|
79
|
-
...(defaultProduct.field_manufacturer
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
...(defaultProduct.field_manufacturer
|
|
104
|
+
? {
|
|
105
|
+
field_manufacturer: {
|
|
106
|
+
title: defaultProduct.field_manufacturer.title,
|
|
107
|
+
status: defaultProduct.field_manufacturer.status,
|
|
108
|
+
body: defaultProduct.field_manufacturer.body.processed,
|
|
109
|
+
field_image: mapImages(defaultProduct.field_manufacturer.field_image, ctx),
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
: {}),
|
|
85
113
|
};
|
|
86
114
|
}
|
|
87
115
|
export function mapProduct(defaultProduct, variationProduct, ctx) {
|
|
88
116
|
const base = mapProductBase(defaultProduct, variationProduct, ctx);
|
|
89
|
-
const relatedProducts = Array.isArray(defaultProduct.field_related_products) &&
|
|
117
|
+
const relatedProducts = Array.isArray(defaultProduct.field_related_products) &&
|
|
118
|
+
defaultProduct.field_related_products[0]?.default_variation
|
|
90
119
|
? defaultProduct.field_related_products.map((related) => mapProductLite(related, related.default_variation, ctx))
|
|
91
120
|
: [];
|
|
92
121
|
return {
|