@q2devel/q2-core 1.0.3 → 1.0.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTerms.d.ts","sourceRoot":"","sources":["../../api/getTerms.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,KAAK,aAAa,GAAG;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,QAAQ,GACnB,KAAK,WAAW,EAChB,
|
|
1
|
+
{"version":3,"file":"getTerms.d.ts","sourceRoot":"","sources":["../../api/getTerms.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,KAAK,aAAa,GAAG;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,QAAQ,GACnB,KAAK,WAAW,EAChB,gCAA0F,aAAa,KACtG,OAAO,CAAC,IAAI,EAAE,CAsEhB,CAAC"}
|
package/dist/api/getTerms.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// api/getTerms.ts
|
|
2
2
|
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
3
3
|
import mapIncludedResources from '../utils/mapIncludedResources';
|
|
4
|
-
export const getTerms = async (ctx, { categoryId, include = ['parent'], mapFn }) => {
|
|
4
|
+
export const getTerms = async (ctx, { categoryId, include = ['parent', 'field_icon', 'field_icon.field_media_image'], mapFn }) => {
|
|
5
5
|
const cacheKey = ['terms', ctx.locale, ...(categoryId ?? []), ...(include ?? [])].join(':');
|
|
6
6
|
// const cached = await ctx.getCache?.<Term[]>(cacheKey);
|
|
7
7
|
// if (cached) return cached;
|
|
@@ -11,7 +11,7 @@ export const getTerms = async (ctx, { categoryId, include = ['parent'], mapFn })
|
|
|
11
11
|
const params = new DrupalJsonApiParams()
|
|
12
12
|
.addInclude(include)
|
|
13
13
|
.addFilter('langcode', ctx.locale)
|
|
14
|
-
.addPageLimit(50);
|
|
14
|
+
.addPageLimit(50);
|
|
15
15
|
if (categoryId) {
|
|
16
16
|
params.addFilter('drupal_internal__tid', categoryId, 'IN');
|
|
17
17
|
}
|
|
@@ -48,6 +48,7 @@ export const getTerms = async (ctx, { categoryId, include = ['parent'], mapFn })
|
|
|
48
48
|
name: item.name,
|
|
49
49
|
description: item.description?.processed ?? '',
|
|
50
50
|
parent: item.parent?.[0],
|
|
51
|
+
icon: item?.field_icon?.field_media_image.uri?.url ? ctx.makeAbsoluteUrl(item.field_icon.field_media_image.uri.url) : undefined,
|
|
51
52
|
};
|
|
52
53
|
return mapFn ? await mapFn(base, item) : base;
|
|
53
54
|
}));
|
package/dist/types/Term.d.ts
CHANGED
package/dist/types/Term.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Term.d.ts","sourceRoot":"","sources":["../../types/Term.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC;IAClB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"Term.d.ts","sourceRoot":"","sources":["../../types/Term.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC;IAClB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B,GAAG,IAAI,CAAC;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AA2CzE,wBAAgB,UAAU,CACxB,cAAc,EAAE,GAAG,EACnB,gBAAgB,EAAE,GAAG,EACrB,aAAa,EAAE,mBAAmB,EAAE,EACpC,GAAG,EAAE,GAAG,GACP,OAAO,CAkCT"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { getDiscountPercent } from '../utils/generalHelper';
|
|
2
|
-
// Pomocná funkce na mapování obrázků
|
|
3
2
|
function mapImages(images, ctx) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const imagesArray = Array.isArray(images)
|
|
4
|
+
? images
|
|
5
|
+
: images
|
|
6
|
+
? [images]
|
|
7
|
+
: [];
|
|
8
|
+
if (imagesArray.length === 0) {
|
|
9
|
+
return [{ href: '/ks_logo.png', alt: 'Q2' }];
|
|
10
|
+
}
|
|
11
|
+
return imagesArray.map((img) => ({
|
|
7
12
|
href: ctx.makeAbsoluteUrl(img.field_media_image?.uri?.url),
|
|
8
13
|
alt: img.name ?? 'Image',
|
|
9
14
|
}));
|
|
@@ -27,8 +32,8 @@ function mapVariations(variations = []) {
|
|
|
27
32
|
}
|
|
28
33
|
// Hlavní mapovací funkce
|
|
29
34
|
export function mapProduct(defaultProduct, variationProduct, allVariations, ctx) {
|
|
30
|
-
const defaultImages = defaultProduct.field_image
|
|
31
|
-
const variationImages = variationProduct.field_image
|
|
35
|
+
const defaultImages = defaultProduct.field_image;
|
|
36
|
+
const variationImages = variationProduct.field_image;
|
|
32
37
|
const discountPercent = getDiscountPercent(variationProduct.price, variationProduct.list_price);
|
|
33
38
|
const badges = [
|
|
34
39
|
...(variationProduct.field_news ? [{ text: 'Novinka', color: 'bg-green-100 text-green-800' }] : []),
|
|
@@ -47,9 +52,7 @@ export function mapProduct(defaultProduct, variationProduct, allVariations, ctx)
|
|
|
47
52
|
product_name: defaultProduct.title,
|
|
48
53
|
changed: variationProduct.changed,
|
|
49
54
|
category: defaultProduct.field_category ?? '',
|
|
50
|
-
variation_images: variationImages
|
|
51
|
-
? [{ href: ctx.makeAbsoluteUrl(variationImages.field_media_image.uri.url), alt: variationProduct.title }]
|
|
52
|
-
: [{ href: '/ks_logo.png', alt: 'Q2' }],
|
|
55
|
+
variation_images: mapImages(variationImages, ctx),
|
|
53
56
|
default_images: mapImages(defaultImages, ctx),
|
|
54
57
|
badges,
|
|
55
58
|
variations: mapVariations(defaultProduct.variations),
|