@q2devel/q2-core 1.0.3 → 1.0.5
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/cart/Cart.service.js +2 -2
- package/dist/api/getTerms.d.ts.map +1 -1
- package/dist/api/getTerms.js +3 -2
- package/dist/api/pages/branch/branch.service.d.ts +9 -0
- package/dist/api/pages/branch/branch.service.d.ts.map +1 -0
- package/dist/api/pages/branch/branch.service.js +39 -0
- package/dist/api/pages/branch/branchService.types.d.ts +16 -0
- package/dist/api/pages/branch/branchService.types.d.ts.map +1 -0
- package/dist/api/pages/branch/branchService.types.js +1 -0
- package/dist/api/pages/faq/faq.service.d.ts +9 -0
- package/dist/api/pages/faq/faq.service.d.ts.map +1 -0
- package/dist/api/pages/faq/faq.service.js +33 -0
- package/dist/api/pages/faq/faqService.types.d.ts +11 -0
- package/dist/api/pages/faq/faqService.types.d.ts.map +1 -0
- package/dist/api/pages/faq/faqService.types.js +1 -0
- package/dist/api/pages/page/page.service.d.ts +10 -0
- package/dist/api/pages/page/page.service.d.ts.map +1 -0
- package/dist/api/pages/page/page.service.js +33 -0
- package/dist/api/pages/page/pageService.types.d.ts +8 -0
- package/dist/api/pages/page/pageService.types.d.ts.map +1 -0
- package/dist/api/pages/page/pageService.types.js +1 -0
- package/dist/api/products/getProducts.d.ts.map +1 -1
- package/dist/api/products/getProducts.js +2 -2
- package/dist/api/user/getUser/user.service.d.ts +8 -0
- package/dist/api/user/getUser/user.service.d.ts.map +1 -0
- package/dist/api/user/getUser/user.service.js +25 -0
- package/dist/api/user/getUser/userService.types.d.ts +42 -0
- package/dist/api/user/getUser/userService.types.d.ts.map +1 -0
- package/dist/api/user/getUser/userService.types.js +1 -0
- package/dist/api/user/register/Register.service.d.ts +8 -0
- package/dist/api/user/register/Register.service.d.ts.map +1 -0
- package/dist/api/user/register/Register.service.js +24 -0
- package/dist/api/user/register/RegisterService.types.d.ts +13 -0
- package/dist/api/user/register/RegisterService.types.d.ts.map +1 -0
- package/dist/api/user/register/RegisterService.types.js +1 -0
- package/dist/api/user/resetPassword/resetPassword.service.d.ts +8 -0
- package/dist/api/user/resetPassword/resetPassword.service.d.ts.map +1 -0
- package/dist/api/user/resetPassword/resetPassword.service.js +4 -0
- package/dist/api/user/resetPassword/resetPasswordSevice.types.d.ts +8 -0
- package/dist/api/user/resetPassword/resetPasswordSevice.types.d.ts.map +1 -0
- package/dist/api/user/resetPassword/resetPasswordSevice.types.js +1 -0
- package/dist/api/wishlist/Wishlist.service.js +1 -1
- package/dist/hooks/user/useGetUser.d.ts +3 -0
- package/dist/hooks/user/useGetUser.d.ts.map +1 -0
- package/dist/hooks/user/useGetUser.js +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/types/Term.d.ts +1 -0
- package/dist/types/Term.d.ts.map +1 -1
- package/dist/types/products/Product.d.ts +2 -0
- package/dist/types/products/Product.d.ts.map +1 -1
- package/dist/utils/mapProducts.d.ts +3 -2
- package/dist/utils/mapProducts.d.ts.map +1 -1
- package/dist/utils/mapProducts.js +29 -14
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ export const getUserCart = async (ctx, config = {}) => {
|
|
|
43
43
|
console.warn('Invalid order item structure', item);
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
|
-
const baseProduct = mapProduct(defaultProduct, variationProduct,
|
|
46
|
+
const baseProduct = mapProduct(defaultProduct, variationProduct, ctx);
|
|
47
47
|
return {
|
|
48
48
|
...baseProduct,
|
|
49
49
|
quantity: parseFloat(item.quantity || '0'),
|
|
@@ -87,7 +87,7 @@ export const getCurrentCart = async (ctx, activeToken, config = {}) => {
|
|
|
87
87
|
console.warn('Invalid order item structure', item);
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
|
-
const baseProduct = mapProduct(defaultProduct, variationProduct,
|
|
90
|
+
const baseProduct = mapProduct(defaultProduct, variationProduct, ctx);
|
|
91
91
|
return {
|
|
92
92
|
...baseProduct,
|
|
93
93
|
quantity: parseFloat(item.quantity || '0'),
|
|
@@ -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
|
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CoreContext } from '../../../context';
|
|
2
|
+
import { Contact } from './branchService.types';
|
|
3
|
+
type GetBranchInput = {
|
|
4
|
+
include?: string[];
|
|
5
|
+
mapFn?: (base: Contact, raw: any) => Contact;
|
|
6
|
+
};
|
|
7
|
+
export declare const getBranch: (ctx: CoreContext, { include, mapFn }: GetBranchInput) => Promise<Contact | null>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=branch.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/branch/branch.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,SAAS,GACpB,KAAK,WAAW,EAChB,oBAAuC,cAAc,KACpD,OAAO,CAAC,OAAO,GAAG,IAAI,CA8CxB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
2
|
+
import mapIncludedResources from '../../../utils/mapIncludedResources';
|
|
3
|
+
export const getBranch = async (ctx, { include = ['field_branch'], mapFn }) => {
|
|
4
|
+
const cacheKey = ['branch', ctx.locale].join(':');
|
|
5
|
+
// const cached = await ctx.redis.get(cacheKey);
|
|
6
|
+
// if (cached) {
|
|
7
|
+
// return cached as Contact;
|
|
8
|
+
// }
|
|
9
|
+
const url = ctx.locale === ctx.defaultLocale
|
|
10
|
+
? `/jsonapi/node/contact_page`
|
|
11
|
+
: `/${ctx.locale}/jsonapi/node/contact_page`;
|
|
12
|
+
const params = new DrupalJsonApiParams()
|
|
13
|
+
.addFilter('langcode', ctx.locale)
|
|
14
|
+
.addInclude(include);
|
|
15
|
+
const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
|
|
16
|
+
const resources = mapIncludedResources(data);
|
|
17
|
+
const contactBranchSection = resources?.[0];
|
|
18
|
+
if (!contactBranchSection)
|
|
19
|
+
return null;
|
|
20
|
+
const base = {
|
|
21
|
+
uuid: contactBranchSection.id,
|
|
22
|
+
id: contactBranchSection.drupal_internal__nid,
|
|
23
|
+
type: contactBranchSection.type,
|
|
24
|
+
title: contactBranchSection.title,
|
|
25
|
+
body: contactBranchSection.field_body,
|
|
26
|
+
branches: contactBranchSection.field_branch?.map((b) => ({
|
|
27
|
+
name: b.field_adress?.organization,
|
|
28
|
+
address1: b.field_adress?.address_line1,
|
|
29
|
+
address2: b.field_adress?.address_line2,
|
|
30
|
+
address3: b.field_adress?.address_line3,
|
|
31
|
+
city: b.field_adress?.locality,
|
|
32
|
+
postal_code: b.field_adress?.postal_code,
|
|
33
|
+
note: b.field_note,
|
|
34
|
+
})) || [],
|
|
35
|
+
};
|
|
36
|
+
const mapped = mapFn ? mapFn(base, contactBranchSection) : base;
|
|
37
|
+
// await ctx.redis.set(cacheKey, mapped);
|
|
38
|
+
return mapped;
|
|
39
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Contact = {
|
|
2
|
+
uuid: string;
|
|
3
|
+
id: string;
|
|
4
|
+
type: string;
|
|
5
|
+
title: string;
|
|
6
|
+
body?: string;
|
|
7
|
+
branches: {
|
|
8
|
+
name: string;
|
|
9
|
+
address1: string;
|
|
10
|
+
address2?: string;
|
|
11
|
+
address3?: string;
|
|
12
|
+
postal_code: string;
|
|
13
|
+
note?: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=branchService.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branchService.types.d.ts","sourceRoot":"","sources":["../../../../api/pages/branch/branchService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;CACP,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CoreContext } from '../../../context';
|
|
2
|
+
import { Faq } from './faqService.types';
|
|
3
|
+
type GetFaqInput = {
|
|
4
|
+
include?: string[];
|
|
5
|
+
mapFn?: (base: Faq, raw: any) => Faq;
|
|
6
|
+
};
|
|
7
|
+
export declare const getFaq: (ctx: CoreContext, { include, mapFn }: GetFaqInput) => Promise<Faq | null>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=faq.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faq.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/faq/faq.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,KAAK,WAAW,EAChB,oBAA0C,WAAW,KACpD,OAAO,CAAC,GAAG,GAAG,IAAI,CAwCpB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
2
|
+
import mapIncludedResources from '../../../utils/mapIncludedResources';
|
|
3
|
+
export const getFaq = async (ctx, { include = ['field_questions'], mapFn }) => {
|
|
4
|
+
const cacheKey = ['faq', ctx.locale].join(':');
|
|
5
|
+
// const cached = await ctx.redis.get(cacheKey);
|
|
6
|
+
// if (cached) {
|
|
7
|
+
// return cached as Faq;
|
|
8
|
+
// }
|
|
9
|
+
const url = ctx.locale === ctx.defaultLocale
|
|
10
|
+
? `/jsonapi/node/faq`
|
|
11
|
+
: `/${ctx.locale}/jsonapi/node/faq`;
|
|
12
|
+
const params = new DrupalJsonApiParams()
|
|
13
|
+
.addFilter('langcode', ctx.locale)
|
|
14
|
+
.addInclude(include);
|
|
15
|
+
const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
|
|
16
|
+
const resources = mapIncludedResources(data);
|
|
17
|
+
const faqItem = resources?.[0];
|
|
18
|
+
if (!faqItem)
|
|
19
|
+
return null;
|
|
20
|
+
const base = {
|
|
21
|
+
uuid: faqItem.id,
|
|
22
|
+
id: faqItem.drupal_internal__nid,
|
|
23
|
+
type: faqItem.type,
|
|
24
|
+
title: faqItem.title,
|
|
25
|
+
items: faqItem.field_questions?.map((q) => ({
|
|
26
|
+
question: q.field_question,
|
|
27
|
+
answer: q.field_answer,
|
|
28
|
+
})) || [],
|
|
29
|
+
};
|
|
30
|
+
const mapped = mapFn ? mapFn(base, faqItem) : base;
|
|
31
|
+
// await ctx.redis.set(cacheKey, mapped);
|
|
32
|
+
return mapped;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faqService.types.d.ts","sourceRoot":"","sources":["../../../../api/pages/faq/faqService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;CACP,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CoreContext } from '../../../context';
|
|
2
|
+
import { Page } from './pageService.types';
|
|
3
|
+
type GetPageInput = {
|
|
4
|
+
pageId: string;
|
|
5
|
+
include?: string[];
|
|
6
|
+
mapFn?: (base: Page, raw: any) => Page;
|
|
7
|
+
};
|
|
8
|
+
export declare const getPage: (ctx: CoreContext, { pageId, include, mapFn }: GetPageInput) => Promise<Page | null>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=page.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.service.d.ts","sourceRoot":"","sources":["../../../../api/pages/page/page.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,KAAK,WAAW,EAChB,4BAA4C,YAAY,KACvD,OAAO,CAAC,IAAI,GAAG,IAAI,CAwCrB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
2
|
+
import mapIncludedResources from '../../../utils/mapIncludedResources';
|
|
3
|
+
export const getPage = async (ctx, { pageId, include = ['node_type'], mapFn }) => {
|
|
4
|
+
const cacheKey = ['page', ctx.locale, pageId].join(':');
|
|
5
|
+
// const cached = await ctx.redis.get(cacheKey);
|
|
6
|
+
// if (cached) {
|
|
7
|
+
// return cached as Page;
|
|
8
|
+
// }
|
|
9
|
+
const url = ctx.locale === ctx.defaultLocale
|
|
10
|
+
? `/jsonapi/node/page`
|
|
11
|
+
: `/${ctx.locale}/jsonapi/node/page`;
|
|
12
|
+
const params = new DrupalJsonApiParams()
|
|
13
|
+
.addFilter('drupal_internal__nid', pageId)
|
|
14
|
+
.addFilter('langcode', ctx.locale)
|
|
15
|
+
.addInclude(include);
|
|
16
|
+
const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
|
|
17
|
+
const resources = mapIncludedResources(data);
|
|
18
|
+
if (!resources.length)
|
|
19
|
+
return null;
|
|
20
|
+
const mappedPages = resources.map((item) => {
|
|
21
|
+
const base = {
|
|
22
|
+
uuid: item.id,
|
|
23
|
+
id: item.drupal_internal__nid,
|
|
24
|
+
type: item.type,
|
|
25
|
+
title: item.title,
|
|
26
|
+
body: item.body?.processed,
|
|
27
|
+
};
|
|
28
|
+
return mapFn ? mapFn(base, item) : base;
|
|
29
|
+
});
|
|
30
|
+
const page = mappedPages[0];
|
|
31
|
+
// await ctx.redis.set(cacheKey, page);
|
|
32
|
+
return page;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageService.types.d.ts","sourceRoot":"","sources":["../../../../api/pages/page/pageService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProducts.d.ts","sourceRoot":"","sources":["../../../api/products/getProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAGvD,KAAK,iBAAiB,GAAG;IACvB,UAAU,CAAC,EAAE,MAAM,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QAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3E,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,KAAK,WAAW,EAChB,4GAkBG,iBAAiB,KACnB,OAAO,CAAC,OAAO,EAAE,CAuDnB,CAAC;AAGF,KAAK,qBAAqB,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,KAAK,WAAW,EAChB,6BAIG,qBAAqB,KACvB,OAAO,CAAC,MAAM,CAkChB,CAAC"}
|
|
@@ -48,9 +48,9 @@ export const getProducts = async (ctx, { categoryId, productId, searchTerm, limi
|
|
|
48
48
|
? `/jsonapi/index/variation`
|
|
49
49
|
: `/${ctx.locale}/jsonapi/index/variation`;
|
|
50
50
|
const { data } = await ctx.axios.get(`${url}?${params.getQueryString()}`);
|
|
51
|
-
const resolvedProducts = mapIncludedResources(data);
|
|
51
|
+
const resolvedProducts = mapIncludedResources(data, 5);
|
|
52
52
|
const mappedProducts = await Promise.all(resolvedProducts.map(async (item) => {
|
|
53
|
-
const base = mapProduct(item.product_id, item,
|
|
53
|
+
const base = mapProduct(item.product_id, item, ctx);
|
|
54
54
|
if (mapFnVariations) {
|
|
55
55
|
return await mapFnVariations(base, item);
|
|
56
56
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CoreContext } from '../../../context';
|
|
2
|
+
import { User } from './userService.types';
|
|
3
|
+
type GetUserInput = {
|
|
4
|
+
mapFn?: (base: User, raw: any) => User;
|
|
5
|
+
};
|
|
6
|
+
export declare const getUser: (ctx: CoreContext, { mapFn }?: GetUserInput) => Promise<User | null>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=user.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../../../api/user/getUser/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,KAAK,WAAW,EAChB,YAAW,YAAiB,KAC3B,OAAO,CAAC,IAAI,GAAG,IAAI,CAoCrB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
2
|
+
export const getUser = async (ctx, { mapFn } = {}) => {
|
|
3
|
+
const params = new DrupalJsonApiParams();
|
|
4
|
+
if (ctx.userId) {
|
|
5
|
+
params.addFilter('drupal_internal__uid', ctx.userId, 'IN');
|
|
6
|
+
}
|
|
7
|
+
const queryString = params.getQueryString();
|
|
8
|
+
const headers = ctx.accessToken
|
|
9
|
+
? { Authorization: `Bearer ${ctx.accessToken}` }
|
|
10
|
+
: undefined;
|
|
11
|
+
const { data } = await ctx.axios.get(`/jsonapi/user/user?${queryString}`, { headers });
|
|
12
|
+
const firstItem = data.data?.[0];
|
|
13
|
+
if (!firstItem)
|
|
14
|
+
return null;
|
|
15
|
+
const customerId = firstItem?.relationships?.customer_profiles?.data?.[0]?.id;
|
|
16
|
+
let mappedUser = {
|
|
17
|
+
name: firstItem?.attributes?.name ?? '',
|
|
18
|
+
email: firstItem?.attributes?.mail ?? '',
|
|
19
|
+
};
|
|
20
|
+
if (customerId) {
|
|
21
|
+
const { data: customerData } = await ctx.axios.get(`/jsonapi/profile/customer/${customerId}`, { headers });
|
|
22
|
+
mappedUser.address = customerData.data.attributes.address;
|
|
23
|
+
}
|
|
24
|
+
return mapFn ? mapFn(mappedUser, firstItem) : mappedUser;
|
|
25
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type JsonApiResponse<T> = {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
jsonapi: {
|
|
4
|
+
version: string;
|
|
5
|
+
meta: {
|
|
6
|
+
links: {
|
|
7
|
+
self: {
|
|
8
|
+
href: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
data: T[];
|
|
14
|
+
included: any;
|
|
15
|
+
links: {
|
|
16
|
+
self: {
|
|
17
|
+
href: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type UserAddress = {
|
|
22
|
+
additional_name: string | null;
|
|
23
|
+
address_line1: string;
|
|
24
|
+
address_line2: string;
|
|
25
|
+
administrative_area: string | null;
|
|
26
|
+
country_code: string;
|
|
27
|
+
dependent_locality: string | null;
|
|
28
|
+
family_name: string;
|
|
29
|
+
given_name: string;
|
|
30
|
+
langcode: string;
|
|
31
|
+
locality: string;
|
|
32
|
+
organization: string;
|
|
33
|
+
postal_code: string;
|
|
34
|
+
sorting_code: string | null;
|
|
35
|
+
};
|
|
36
|
+
export type User = {
|
|
37
|
+
name: string;
|
|
38
|
+
email: string;
|
|
39
|
+
field_name?: string;
|
|
40
|
+
address?: UserAddress;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=userService.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userService.types.d.ts","sourceRoot":"","sources":["../../../../api/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
+
import { Request, Response } from './RegisterService.types';
|
|
3
|
+
type RegisterUserInput = Request & {
|
|
4
|
+
mapFn?: (raw: any) => Response['data'];
|
|
5
|
+
};
|
|
6
|
+
export declare const registerUser: (ctx: CoreContext, { email, name, password, mapFn }: RegisterUserInput) => Promise<Response>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=Register.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Register.service.d.ts","sourceRoot":"","sources":["../../../../api/user/register/Register.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,iBAAiB,GAAG,OAAO,GAAG;IACjC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,KAAK,WAAW,EAChB,kCAAkC,iBAAiB,KAClD,OAAO,CAAC,QAAQ,CA6BlB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const registerUser = async (ctx, { email, name, password, mapFn }) => {
|
|
2
|
+
const payload = {
|
|
3
|
+
data: {
|
|
4
|
+
type: 'user--user',
|
|
5
|
+
attributes: {
|
|
6
|
+
field_name: name,
|
|
7
|
+
name: email,
|
|
8
|
+
mail: email,
|
|
9
|
+
pass: password,
|
|
10
|
+
langocode: ctx.locale,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const res = await ctx.axios.post('/jsonapi/user/register', payload, {
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/vnd.api+json',
|
|
17
|
+
Accept: 'application/vnd.api+json',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
data: mapFn ? mapFn(res.data.data) : res.data.data,
|
|
22
|
+
status: res.status,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisterService.types.d.ts","sourceRoot":"","sources":["../../../../api/user/register/RegisterService.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CoreContext } from '../../../context';
|
|
2
|
+
import { Response } from './resetPasswordSevice.types';
|
|
3
|
+
type ResetPasswordParams = {
|
|
4
|
+
email: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const resetPassword: (ctx: CoreContext, { email }: ResetPasswordParams) => Promise<Response>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=resetPassword.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resetPassword.service.d.ts","sourceRoot":"","sources":["../../../../api/user/resetPassword/resetPassword.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,KAAK,WAAW,EAChB,WAAW,mBAAmB,KAC7B,OAAO,CAAC,QAAQ,CAGlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resetPasswordSevice.types.d.ts","sourceRoot":"","sources":["../../../../api/user/resetPassword/resetPasswordSevice.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -58,7 +58,7 @@ export const getWishlistItems = async (ctx, wishlistIds, config = {}) => {
|
|
|
58
58
|
}
|
|
59
59
|
const params = new DrupalJsonApiParams()
|
|
60
60
|
.addFilter('wishlist_id.meta.drupal_internal__target_id', wishlistIds, 'IN')
|
|
61
|
-
.addInclude(['variation_id', 'wishlist_id', 'variation_id.product_id']);
|
|
61
|
+
.addInclude(['variation_id', 'wishlist_id', 'variation_id.product_id', 'variation_id.field_image.field_media_image']);
|
|
62
62
|
const { data } = await ctx.axios.get(`/jsonapi/wishlist_item/wishlist_item?${params.getQueryString()}`, {
|
|
63
63
|
...config,
|
|
64
64
|
headers: getHeaders(ctx, config.headers),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetUser.d.ts","sourceRoot":"","sources":["../../../hooks/user/useGetUser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,UAAU,GAAI,KAAK,WAAW,uFAQ1C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { getUser } from '../../api/user/getUser/user.service';
|
|
3
|
+
export const useGetUser = (ctx) => {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['user', ctx.userId],
|
|
6
|
+
queryFn: async ({ signal }) => {
|
|
7
|
+
return getUser(ctx, { mapFn: (user) => user });
|
|
8
|
+
},
|
|
9
|
+
enabled: !!ctx.userId,
|
|
10
|
+
});
|
|
11
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,17 @@ export * from './api/getTerms';
|
|
|
6
6
|
export * from './types/Term';
|
|
7
7
|
export * from './api/products/getProducts';
|
|
8
8
|
export * from './types/products/Product';
|
|
9
|
+
export * from './api/pages/page/pageService.types';
|
|
10
|
+
export * from './api/pages/page/page.service';
|
|
11
|
+
export * from './api/pages/faq/faqService.types';
|
|
12
|
+
export * from './api/pages/faq/faq.service';
|
|
13
|
+
export * from './api/pages/branch/branchService.types';
|
|
14
|
+
export * from './api/pages/branch/branch.service';
|
|
15
|
+
export * from './api/user/register/Register.service';
|
|
16
|
+
export * from './api/user/resetPassword/resetPassword.service';
|
|
17
|
+
export * from './api/user/getUser/user.service';
|
|
18
|
+
export * from './api/user/getUser/userService.types';
|
|
19
|
+
export * from './hooks/user/useGetUser';
|
|
9
20
|
export * from './api/checkout/Checkout.service';
|
|
10
21
|
export * from './api/checkout/CheckoutService.types';
|
|
11
22
|
export * from './hooks/cart/api/useGetOrderHistory';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAG7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAGzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAE5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAGlD,cAAc,sCAAsC,CAAA;AACpD,cAAc,gDAAgD,CAAC;AAE/D,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yBAAyB,CAAC;AAGxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AAErD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAE7C,cAAc,WAAW,CAAC;AAC1B,cAAc,8BAA8B,CAAC;AAE7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AAGxC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
+
//content
|
|
1
2
|
export * from './api/content/getBanners';
|
|
2
3
|
export * from './api/content/getBlog';
|
|
3
4
|
export * from './types/content/Banners';
|
|
4
5
|
export * from './types/content/Blog';
|
|
6
|
+
//terms
|
|
5
7
|
export * from './api/getTerms';
|
|
6
8
|
export * from './types/Term';
|
|
9
|
+
//products
|
|
7
10
|
export * from './api/products/getProducts';
|
|
8
11
|
export * from './types/products/Product';
|
|
12
|
+
// pages
|
|
13
|
+
export * from './api/pages/page/pageService.types';
|
|
14
|
+
export * from './api/pages/page/page.service';
|
|
15
|
+
export * from './api/pages/faq/faqService.types';
|
|
16
|
+
export * from './api/pages/faq/faq.service';
|
|
17
|
+
export * from './api/pages/branch/branchService.types';
|
|
18
|
+
export * from './api/pages/branch/branch.service';
|
|
19
|
+
//uesr
|
|
20
|
+
export * from './api/user/register/Register.service';
|
|
21
|
+
export * from './api/user/resetPassword/resetPassword.service';
|
|
22
|
+
export * from './api/user/getUser/user.service';
|
|
23
|
+
export * from './api/user/getUser/userService.types';
|
|
24
|
+
export * from './hooks/user/useGetUser';
|
|
9
25
|
export * from './api/checkout/Checkout.service';
|
|
10
26
|
export * from './api/checkout/CheckoutService.types';
|
|
11
27
|
export * from './hooks/cart/api/useGetOrderHistory';
|
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"}
|
|
@@ -4,6 +4,7 @@ export type Product = {
|
|
|
4
4
|
type: string;
|
|
5
5
|
variation_name: string;
|
|
6
6
|
sku: string;
|
|
7
|
+
ean: number;
|
|
7
8
|
description: string;
|
|
8
9
|
price: number;
|
|
9
10
|
discountPercent: number | null;
|
|
@@ -24,6 +25,7 @@ export type Product = {
|
|
|
24
25
|
text: string;
|
|
25
26
|
color: string;
|
|
26
27
|
}>;
|
|
28
|
+
related_products?: Product[];
|
|
27
29
|
field_news?: boolean;
|
|
28
30
|
field_aftersale?: boolean;
|
|
29
31
|
field_care?: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Product.d.ts","sourceRoot":"","sources":["../../../types/products/Product.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC;IACd,gBAAgB,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;IACJ,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;IACJ,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAGhC,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IAEH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC;IACvB,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,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,eAAe,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,iBAAiB,CAAC,EAAE;YAClB,GAAG,CAAC,EAAE;gBACJ,GAAG,EAAE,MAAM,CAAC;aACb,CAAC;SACH,CAAC;QACF,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function mapProduct(defaultProduct: any, variationProduct: any,
|
|
1
|
+
import { Product } from '../types/products/Product';
|
|
2
|
+
export declare function mapProduct(defaultProduct: any, variationProduct: any, ctx: any): Product;
|
|
3
|
+
export declare function mapProductLite(defaultProduct: any, variationProduct: any, ctx: any): any;
|
|
3
4
|
//# sourceMappingURL=mapProducts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,OAAO,EAAE,MAAM,2BAA2B,CAAC;AA0EzE,wBAAgB,UAAU,CAAC,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAaxF;AAED,wBAAgB,cAAc,CAAC,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAMxF"}
|
|
@@ -1,14 +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) ? images : images ? [images] : [];
|
|
4
|
+
if (imagesArray.length === 0) {
|
|
5
|
+
return [{ href: '/ks_logo.png', alt: 'Q2' }];
|
|
6
|
+
}
|
|
7
|
+
return imagesArray.map((img) => ({
|
|
7
8
|
href: ctx.makeAbsoluteUrl(img.field_media_image?.uri?.url),
|
|
8
9
|
alt: img.name ?? 'Image',
|
|
9
10
|
}));
|
|
10
11
|
}
|
|
11
|
-
// Pomocná funkce na mapování variant
|
|
12
12
|
function mapVariations(variations = []) {
|
|
13
13
|
return variations.map((v) => {
|
|
14
14
|
const discountPercentVariation = getDiscountPercent(v.price, v.list_price);
|
|
@@ -21,14 +21,13 @@ function mapVariations(variations = []) {
|
|
|
21
21
|
discountPercentVariation,
|
|
22
22
|
ean: v.field_ean,
|
|
23
23
|
stock: v?.field_stock_level?.available_stock ?? 0,
|
|
24
|
-
href: ''
|
|
24
|
+
href: '',
|
|
25
25
|
};
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const variationImages = variationProduct.field_image ?? [];
|
|
28
|
+
function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
29
|
+
const defaultImages = defaultProduct.field_image;
|
|
30
|
+
const variationImages = variationProduct.field_image;
|
|
32
31
|
const discountPercent = getDiscountPercent(variationProduct.price, variationProduct.list_price);
|
|
33
32
|
const badges = [
|
|
34
33
|
...(variationProduct.field_news ? [{ text: 'Novinka', color: 'bg-green-100 text-green-800' }] : []),
|
|
@@ -39,7 +38,8 @@ export function mapProduct(defaultProduct, variationProduct, allVariations, ctx)
|
|
|
39
38
|
variation_uuid: variationProduct.id,
|
|
40
39
|
type: variationProduct.type,
|
|
41
40
|
variation_name: variationProduct.title,
|
|
42
|
-
sku: variationProduct.
|
|
41
|
+
sku: variationProduct.sku,
|
|
42
|
+
ean: variationProduct.field_ean,
|
|
43
43
|
description: defaultProduct.field_description?.processed ?? '',
|
|
44
44
|
price: variationProduct?.list_price?.number ? variationProduct.list_price.number : variationProduct.price?.number ?? 0,
|
|
45
45
|
discountPercent,
|
|
@@ -47,9 +47,7 @@ export function mapProduct(defaultProduct, variationProduct, allVariations, ctx)
|
|
|
47
47
|
product_name: defaultProduct.title,
|
|
48
48
|
changed: variationProduct.changed,
|
|
49
49
|
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' }],
|
|
50
|
+
variation_images: mapImages(variationImages, ctx),
|
|
53
51
|
default_images: mapImages(defaultImages, ctx),
|
|
54
52
|
badges,
|
|
55
53
|
variations: mapVariations(defaultProduct.variations),
|
|
@@ -61,3 +59,20 @@ export function mapProduct(defaultProduct, variationProduct, allVariations, ctx)
|
|
|
61
59
|
field_shipping: defaultProduct.field_shipping ?? [],
|
|
62
60
|
};
|
|
63
61
|
}
|
|
62
|
+
export function mapProduct(defaultProduct, variationProduct, ctx) {
|
|
63
|
+
const base = mapProductBase(defaultProduct, variationProduct, ctx);
|
|
64
|
+
const relatedProducts = Array.isArray(defaultProduct.field_related_products) && defaultProduct.field_related_products[0]?.default_variation
|
|
65
|
+
? defaultProduct.field_related_products.map((related) => mapProductLite(related, related.default_variation, ctx))
|
|
66
|
+
: [];
|
|
67
|
+
return {
|
|
68
|
+
...base,
|
|
69
|
+
related_products: relatedProducts,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function mapProductLite(defaultProduct, variationProduct, ctx) {
|
|
73
|
+
// console.log('Mapping product lite', defaultProduct, variationProduct);
|
|
74
|
+
return {
|
|
75
|
+
...mapProductBase(defaultProduct, variationProduct, ctx),
|
|
76
|
+
related_products: [],
|
|
77
|
+
};
|
|
78
|
+
}
|