@q2devel/q2-core 1.0.67 → 1.0.71
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/README.md +13 -3
- package/dist/api/cart/Cart.service.d.ts +3 -3
- package/dist/api/cart/Cart.service.d.ts.map +1 -1
- package/dist/api/cart/Cart.service.js +69 -60
- package/dist/api/cart/CartService.types.d.ts.map +1 -1
- package/dist/api/checkout/Checkout.service.d.ts.map +1 -1
- package/dist/api/checkout/Checkout.service.js +16 -4
- package/dist/api/checkout/CheckoutService.types.d.ts.map +1 -1
- package/dist/api/content/getBanners.d.ts.map +1 -1
- package/dist/api/content/getBanners.js +1 -1
- package/dist/api/content/getBlog.d.ts +1 -1
- package/dist/api/content/getBlog.d.ts.map +1 -1
- package/dist/api/content/getBlog.js +7 -2
- package/dist/api/getTerms.d.ts.map +1 -1
- package/dist/api/getTerms.js +6 -1
- package/dist/api/pages/branch/branch.service.d.ts.map +1 -1
- package/dist/api/pages/branch/branchService.types.d.ts.map +1 -1
- package/dist/api/pages/faq/faq.service.d.ts.map +1 -1
- package/dist/api/pages/faq/faqService.types.d.ts.map +1 -1
- package/dist/api/pages/page/page.service.js +5 -5
- package/dist/api/pages/page/pageService.types.d.ts.map +1 -1
- package/dist/api/products/getProducts.d.ts +2 -2
- package/dist/api/products/getProducts.d.ts.map +1 -1
- package/dist/api/products/getProducts.js +33 -33
- package/dist/api/products/product-detail/QuestionForm.service.d.ts +2 -2
- package/dist/api/products/product-detail/QuestionForm.service.d.ts.map +1 -1
- package/dist/api/user/getUser/user.service.d.ts.map +1 -1
- package/dist/api/user/getUser/user.service.js +3 -1
- package/dist/api/user/register/Register.service.d.ts.map +1 -1
- package/dist/api/user/register/RegisterService.types.d.ts.map +1 -1
- package/dist/api/user/resetPassword/resetPassword.service.d.ts.map +1 -1
- package/dist/api/user/resetPassword/resetPasswordSevice.types.d.ts.map +1 -1
- package/dist/api/wishlist/Wishlist.service.d.ts.map +1 -1
- package/dist/api/wishlist/Wishlist.service.js +6 -1
- package/dist/api/wishlist/WishlistService.types.d.ts +1 -3
- package/dist/api/wishlist/WishlistService.types.d.ts.map +1 -1
- package/dist/auth/auth/auth.d.ts.map +1 -1
- package/dist/auth/context/AuthContext.d.ts.map +1 -1
- package/dist/auth/context/AuthContext.js +3 -2
- package/dist/auth/hooks/useCurrentUser.d.ts.map +1 -1
- package/dist/auth/hooks/useCurrentUser.js +2 -2
- package/dist/auth/hooks/useSignIn.d.ts.map +1 -1
- package/dist/auth/hooks/useSignIn.js +5 -1
- package/dist/auth/hooks/useUrlModal.d.ts.map +1 -1
- package/dist/auth/hooks/useUrlModal.js +3 -1
- package/dist/auth/services/user.service.d.ts.map +1 -1
- package/dist/auth/services/user.service.js +5 -3
- package/dist/context/cart/BasketContext.d.ts +1 -1
- package/dist/context/cart/BasketContext.d.ts.map +1 -1
- package/dist/context/cart/BasketContext.js +6 -4
- package/dist/context.d.ts.map +1 -1
- package/dist/hooks/cart/api/useAddToCart.d.ts.map +1 -1
- package/dist/hooks/cart/api/useClearCart.d.ts.map +1 -1
- package/dist/hooks/cart/api/useDeleteCartItem.d.ts.map +1 -1
- package/dist/hooks/cart/api/useGetCartToken.d.ts.map +1 -1
- package/dist/hooks/cart/api/useGetCurrentCart.d.ts.map +1 -1
- package/dist/hooks/cart/api/useGetOrderHistory.d.ts.map +1 -1
- package/dist/hooks/cart/api/useGetUserCart.d.ts.map +1 -1
- package/dist/hooks/cart/api/useUpdateCart.d.ts.map +1 -1
- package/dist/hooks/cart/api/useUpdateCart.js +6 -2
- package/dist/hooks/checkout/useUpdateCheckout.d.ts.map +1 -1
- package/dist/hooks/checkout/useUpdateCheckout.js +2 -2
- package/dist/hooks/user/useGetUser.d.ts.map +1 -1
- package/dist/hooks/wishlist/api/useAddToWishlist.d.ts.map +1 -1
- package/dist/hooks/wishlist/api/useCreateWishlist.d.ts.map +1 -1
- package/dist/hooks/wishlist/api/useGetWishlistItems.d.ts.map +1 -1
- package/dist/hooks/wishlist/api/useGetWishlistList.d.ts.map +1 -1
- package/dist/hooks/wishlist/api/useGetWishlistList.js +3 -1
- package/dist/hooks/wishlist/useWishlist.d.ts +3 -2
- package/dist/hooks/wishlist/useWishlist.d.ts.map +1 -1
- package/dist/hooks/wishlist/useWishlist.js +53 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/types/Term.d.ts.map +1 -1
- package/dist/types/content/Banners.d.ts.map +1 -1
- package/dist/types/content/Blog.d.ts +1 -1
- package/dist/types/products/Product.d.ts.map +1 -1
- package/dist/utils/generalHelper.d.ts.map +1 -1
- package/dist/utils/generalHelper.js +3 -1
- package/dist/utils/mapIncludedResources.d.ts.map +1 -1
- package/dist/utils/mapProducts.d.ts +1 -1
- package/dist/utils/mapProducts.d.ts.map +1 -1
- package/dist/utils/mapProducts.js +25 -18
- package/package.json +36 -36
|
@@ -6,7 +6,6 @@ import { useDeleteWishlist } from './api/useDeleteWishlist';
|
|
|
6
6
|
import { useDeleteWishlistItem } from './api/useDeleteWishlistItem';
|
|
7
7
|
import { useGetWishlistItems } from './api/useGetWishlistItems';
|
|
8
8
|
import { useGetWishlistList } from './api/useGetWishlistList';
|
|
9
|
-
const FAVORITES_WISHLIST_ID = '1';
|
|
10
9
|
export const useWishlist = (ctx) => {
|
|
11
10
|
// const t = useTranslations('wishlist')
|
|
12
11
|
// const FAVORITES_WISHLIST_NAME = t('default-wishlist')
|
|
@@ -17,20 +16,39 @@ export const useWishlist = (ctx) => {
|
|
|
17
16
|
const { mutate: addToWishlist, isPending: isAddingToWishlist } = useAddToWishlist(ctx);
|
|
18
17
|
const { mutate: deleteWishlist, isPending: isDeletingWishlist } = useDeleteWishlist(ctx);
|
|
19
18
|
const { mutate: deleteWishlistItem, isPending: isDeletingFromWishlist } = useDeleteWishlistItem(ctx);
|
|
20
|
-
const isWishlistPending = isCreatingWishlist ||
|
|
19
|
+
const isWishlistPending = isCreatingWishlist ||
|
|
20
|
+
isAddingToWishlist ||
|
|
21
|
+
isDeletingFromWishlist ||
|
|
22
|
+
isDeletingWishlist;
|
|
21
23
|
const wishlists = useMemo(() => wishlistsData?.wishlist_ids || [], [wishlistsData]);
|
|
22
|
-
|
|
24
|
+
// Najdi favorites wishlist podle názvu
|
|
25
|
+
// Pokud by byly duplicity (což by nemělo být možné), použij ten s nejvíce položkami
|
|
26
|
+
const favoritesWishlist = useMemo(() => {
|
|
27
|
+
const matchingWishlists = wishlists.filter((wishlist) => wishlist.name === FAVORITES_WISHLIST_NAME);
|
|
28
|
+
if (matchingWishlists.length === 0)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (matchingWishlists.length === 1)
|
|
31
|
+
return matchingWishlists[0];
|
|
32
|
+
// Pokud jsou duplicity, použij ten s nejvíce položkami (pravděpodobně správný favorites)
|
|
33
|
+
return matchingWishlists.reduce((prev, current) => current.items_count > prev.items_count ? current : prev);
|
|
34
|
+
}, [wishlists, FAVORITES_WISHLIST_NAME]);
|
|
35
|
+
// Helper pro kontrolu, zda je název rezervovaný pro favorites
|
|
36
|
+
const isFavoritesNameReserved = useCallback((name) => {
|
|
37
|
+
return name.trim() === FAVORITES_WISHLIST_NAME;
|
|
38
|
+
}, [FAVORITES_WISHLIST_NAME]);
|
|
23
39
|
const wishlistIds = useMemo(() => wishlists.map((wishlist) => wishlist.wishlist_id), [wishlists]);
|
|
24
40
|
const { data: wishlistItemsData } = useGetWishlistItems(ctx, wishlistIds);
|
|
25
41
|
const wishlistItems = wishlistItemsData?.data || [];
|
|
26
42
|
const isProductInFavorites = useCallback((productUuid) => {
|
|
27
|
-
if (!wishlistItems.length)
|
|
43
|
+
if (!wishlistItems.length || !favoritesWishlist)
|
|
28
44
|
return false;
|
|
29
45
|
return wishlistItems.some((item) => {
|
|
30
46
|
return (item.variation_id?.id === productUuid &&
|
|
31
|
-
item.wishlist_id?.
|
|
47
|
+
(item.wishlist_id?.id === favoritesWishlist.wishlist_id ||
|
|
48
|
+
item.wishlist_id?.drupal_internal__id?.toString() ===
|
|
49
|
+
favoritesWishlist.wishlist_id));
|
|
32
50
|
});
|
|
33
|
-
}, [wishlistItems]);
|
|
51
|
+
}, [wishlistItems, favoritesWishlist]);
|
|
34
52
|
const isProductInWishlist = useCallback((productUuid) => {
|
|
35
53
|
if (!wishlistItems.length)
|
|
36
54
|
return false;
|
|
@@ -39,11 +57,15 @@ export const useWishlist = (ctx) => {
|
|
|
39
57
|
});
|
|
40
58
|
}, [wishlistItems]);
|
|
41
59
|
const findFavoritesItemForProduct = useCallback((productUuid) => {
|
|
60
|
+
if (!favoritesWishlist)
|
|
61
|
+
return undefined;
|
|
42
62
|
return wishlistItems.find((item) => {
|
|
43
63
|
return (item.variation_id?.id === productUuid &&
|
|
44
|
-
item.wishlist_id?.
|
|
64
|
+
(item.wishlist_id?.id === favoritesWishlist.wishlist_id ||
|
|
65
|
+
item.wishlist_id?.drupal_internal__id?.toString() ===
|
|
66
|
+
favoritesWishlist.wishlist_id));
|
|
45
67
|
});
|
|
46
|
-
}, [wishlistItems]);
|
|
68
|
+
}, [wishlistItems, favoritesWishlist]);
|
|
47
69
|
const handleLikeToggle = useCallback((product) => {
|
|
48
70
|
const isInFavorites = isProductInFavorites(product.variation_uuid);
|
|
49
71
|
if (isInFavorites) {
|
|
@@ -57,7 +79,7 @@ export const useWishlist = (ctx) => {
|
|
|
57
79
|
else {
|
|
58
80
|
if (favoritesWishlist) {
|
|
59
81
|
addToWishlist({
|
|
60
|
-
wishlist_id:
|
|
82
|
+
wishlist_id: favoritesWishlist.wishlist_id,
|
|
61
83
|
variation_id: product.variation_id,
|
|
62
84
|
quantity: 1,
|
|
63
85
|
});
|
|
@@ -68,11 +90,13 @@ export const useWishlist = (ctx) => {
|
|
|
68
90
|
note: '',
|
|
69
91
|
}, {
|
|
70
92
|
onSuccess: (data) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
if (data && data.wishlist_id) {
|
|
94
|
+
addToWishlist({
|
|
95
|
+
wishlist_id: data.wishlist_id,
|
|
96
|
+
variation_id: product.variation_id,
|
|
97
|
+
quantity: 1,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
76
100
|
},
|
|
77
101
|
});
|
|
78
102
|
}
|
|
@@ -96,7 +120,7 @@ export const useWishlist = (ctx) => {
|
|
|
96
120
|
}
|
|
97
121
|
}
|
|
98
122
|
else {
|
|
99
|
-
const nonFavoritesWishlists = wishlists.filter((w) => w.
|
|
123
|
+
const nonFavoritesWishlists = wishlists.filter((w) => w.name !== FAVORITES_WISHLIST_NAME);
|
|
100
124
|
if (nonFavoritesWishlists.length > 0) {
|
|
101
125
|
addToWishlist({
|
|
102
126
|
wishlist_id: nonFavoritesWishlists[0].wishlist_id,
|
|
@@ -110,9 +134,9 @@ export const useWishlist = (ctx) => {
|
|
|
110
134
|
note: '',
|
|
111
135
|
}, {
|
|
112
136
|
onSuccess: (data) => {
|
|
113
|
-
if (data
|
|
137
|
+
if (data && data.wishlist_id) {
|
|
114
138
|
addToWishlist({
|
|
115
|
-
wishlist_id: data.
|
|
139
|
+
wishlist_id: data.wishlist_id,
|
|
116
140
|
variation_id: product.variation_id,
|
|
117
141
|
quantity: 1,
|
|
118
142
|
});
|
|
@@ -137,23 +161,28 @@ export const useWishlist = (ctx) => {
|
|
|
137
161
|
});
|
|
138
162
|
}, [addToWishlist]);
|
|
139
163
|
const handleCreateWishlist = useCallback((name, product) => {
|
|
164
|
+
// Validace: zabránit vytvoření wishlistu se stejným názvem jako favorites
|
|
165
|
+
if (isFavoritesNameReserved(name)) {
|
|
166
|
+
console.warn(`Cannot create wishlist with reserved name: "${name}". This name is reserved for favorites.`);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
140
169
|
createWishlist({
|
|
141
170
|
name,
|
|
142
171
|
note: '',
|
|
143
172
|
}, {
|
|
144
173
|
onSuccess: (data) => {
|
|
145
|
-
if (data
|
|
174
|
+
if (data && data.wishlist_id) {
|
|
146
175
|
addToWishlist({
|
|
147
|
-
wishlist_id: data.
|
|
176
|
+
wishlist_id: data.wishlist_id,
|
|
148
177
|
variation_id: product.variation_id,
|
|
149
178
|
quantity: 1,
|
|
150
179
|
});
|
|
151
180
|
}
|
|
152
181
|
},
|
|
153
182
|
});
|
|
154
|
-
}, [createWishlist, addToWishlist]);
|
|
183
|
+
}, [createWishlist, addToWishlist, isFavoritesNameReserved]);
|
|
155
184
|
const wishlistsForDropdown = wishlists
|
|
156
|
-
.filter((wishlist) => wishlist.
|
|
185
|
+
.filter((wishlist) => wishlist.name !== FAVORITES_WISHLIST_NAME)
|
|
157
186
|
.map((wishlist) => ({
|
|
158
187
|
id: wishlist.wishlist_id,
|
|
159
188
|
name: wishlist.name,
|
|
@@ -170,7 +199,8 @@ export const useWishlist = (ctx) => {
|
|
|
170
199
|
}, [wishlistItems]);
|
|
171
200
|
const handleRemoveFromWishlist = useCallback((product, wishlistId) => {
|
|
172
201
|
const wishlistItem = wishlistItems.find((item) => item.variation_id?.id === product.variation_uuid &&
|
|
173
|
-
item.wishlist_id?.drupal_internal__id?.toString() ===
|
|
202
|
+
item.wishlist_id?.drupal_internal__id?.toString() ===
|
|
203
|
+
wishlistId);
|
|
174
204
|
if (wishlistItem) {
|
|
175
205
|
deleteWishlistItem({
|
|
176
206
|
wishlist_item_id: wishlistItem.drupal_internal__id.toString(),
|
|
@@ -198,5 +228,6 @@ export const useWishlist = (ctx) => {
|
|
|
198
228
|
handleDeleteWishlist,
|
|
199
229
|
favoritesWishlist,
|
|
200
230
|
wishlistItems,
|
|
231
|
+
isFavoritesNameReserved,
|
|
201
232
|
};
|
|
202
233
|
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AAErC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AAGpC,cAAc,g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c,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AAEvC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sCAAsC,CAAA;AAEpD,cAAc,qCAAqC,CAAA;AACnD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iCAAiC,CAAA;AAE/C,cAAc,WAAW,CAAA;AACzB,cAAc,8BAA8B,CAAA;AAE5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAE5C,cAAc,qBAAqB,CAAA;AACnC,cAAc,8BAA8B,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
|
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;
|
|
1
|
+
{"version":3,"file":"Term.d.ts","sourceRoot":"","sources":["../../types/Term.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA;IACjB,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAA;QACZ,EAAE,EAAE,MAAM,CAAA;QACV,oBAAoB,CAAC,EAAE,MAAM,CAAA;KAChC,GAAG,IAAI,CAAA;IACR,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banners.d.ts","sourceRoot":"","sources":["../../../types/content/Banners.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;
|
|
1
|
+
{"version":3,"file":"Banners.d.ts","sourceRoot":"","sources":["../../../types/content/Banners.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE;QACT,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAClB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Product.d.ts","sourceRoot":"","sources":["../../../types/products/Product.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"Product.d.ts","sourceRoot":"","sources":["../../../types/products/Product.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,EAAE,GAAG,CAAA;IACb,gBAAgB,EAAE;QACd,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;IACH,cAAc,EAAE;QACZ,IAAI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"","sources":["../../utils/generalHelper.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;
|
|
1
|
+
{"version":3,"file":"generalHelper.d.ts","sourceRoot":"","sources":["../../utils/generalHelper.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,kBAAkB,CAC9B,KAAK,CAAC,EAAE,KAAK,EACb,SAAS,CAAC,EAAE,KAAK,GAClB,MAAM,GAAG,IAAI,CAWf;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM;;;SAe1C;AAED,eAAO,MAAM,iBAAiB,QAAO,MAEpC,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,WAexD,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export function getDiscountPercent(price, listPrice) {
|
|
2
|
-
if (!price?.number ||
|
|
2
|
+
if (!price?.number ||
|
|
3
|
+
!listPrice?.number ||
|
|
4
|
+
listPrice.number === price.number) {
|
|
3
5
|
return 0;
|
|
4
6
|
}
|
|
5
7
|
const discount = ((price.number - listPrice.number) / price.number) * 100;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapIncludedResources.d.ts","sourceRoot":"","sources":["../../utils/mapIncludedResources.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,aAAa,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mapIncludedResources.d.ts","sourceRoot":"","sources":["../../utils/mapIncludedResources.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,aAAa,CAAC,EAAE,MAAM,CAClB,MAAM,EACN;QACI,IAAI,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KACtE,CACJ,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,eAAe,EAAE,GAAG,eAAe,CAAA;IACzC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAA;CAC/B,CAAA;AAED,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,GAAG,EACxC,IAAI,EAAE,eAAe,EACrB,QAAQ,SAAI,GACb,CAAC,EAAE,CAkDL;AAED,eAAe,oBAAoB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Product } from
|
|
1
|
+
import { Product } from '../types/products/Product';
|
|
2
2
|
export declare function mapProduct(defaultProduct: any, variationProduct: any, ctx: any): Product;
|
|
3
3
|
export declare function mapProductLite(defaultProduct: any, variationProduct: any, ctx: any): any;
|
|
4
4
|
//# sourceMappingURL=mapProducts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"mapProducts.d.ts","sourceRoot":"","sources":["../../utils/mapProducts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,2BAA2B,CAAA;AAgLxE,wBAAgB,UAAU,CACtB,cAAc,EAAE,GAAG,EACnB,gBAAgB,EAAE,GAAG,EACrB,GAAG,EAAE,GAAG,GACT,OAAO,CAeT;AAED,wBAAgB,cAAc,CAC1B,cAAc,EAAE,GAAG,EACnB,gBAAgB,EAAE,GAAG,EACrB,GAAG,EAAE,GAAG,GACT,GAAG,CAKL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDiscountPercent } from
|
|
1
|
+
import { getDiscountPercent } from '../utils/generalHelper';
|
|
2
2
|
function getImageUrl(img) {
|
|
3
3
|
if (img?.field_media_image?.uri?.url) {
|
|
4
4
|
return img.field_media_image.uri.url;
|
|
@@ -9,30 +9,30 @@ function getImageUrl(img) {
|
|
|
9
9
|
if (img?.uri) {
|
|
10
10
|
return img.uri;
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return '';
|
|
13
13
|
}
|
|
14
14
|
function mapImages(images, ctx) {
|
|
15
15
|
const imagesArray = Array.isArray(images) ? images : images ? [images] : [];
|
|
16
16
|
if (imagesArray.length === 0) {
|
|
17
|
-
return [{ href: ctx.logoUrl ||
|
|
17
|
+
return [{ href: ctx.logoUrl || '/logo.png', alt: 'Q2' }];
|
|
18
18
|
}
|
|
19
19
|
const result = imagesArray.map((img) => {
|
|
20
20
|
const imageUrl = getImageUrl(img);
|
|
21
21
|
if (!imageUrl) {
|
|
22
22
|
return {
|
|
23
|
-
href: ctx.logoUrl ||
|
|
24
|
-
alt: img.name ??
|
|
23
|
+
href: ctx.logoUrl || '/logo.png',
|
|
24
|
+
alt: img.name ?? 'Image',
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
if (imageUrl.startsWith(
|
|
27
|
+
if (imageUrl.startsWith('http')) {
|
|
28
28
|
return {
|
|
29
29
|
href: imageUrl,
|
|
30
|
-
alt: img.name ??
|
|
30
|
+
alt: img.name ?? 'Image',
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
return {
|
|
34
34
|
href: ctx.makeAbsoluteUrl(imageUrl),
|
|
35
|
-
alt: img.name ??
|
|
35
|
+
alt: img.name ?? 'Image',
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
return result;
|
|
@@ -45,11 +45,13 @@ function mapVariations(variations = []) {
|
|
|
45
45
|
id: v.drupal_internal__variation_id,
|
|
46
46
|
title: v.title,
|
|
47
47
|
sku: v.sku,
|
|
48
|
-
price: v?.list_price?.number
|
|
48
|
+
price: v?.list_price?.number
|
|
49
|
+
? v.list_price.number
|
|
50
|
+
: (v.price?.number ?? 0),
|
|
49
51
|
discountPercentVariation,
|
|
50
52
|
ean: v.field_ean,
|
|
51
53
|
stock: v?.field_stock_level?.available_stock ?? 0,
|
|
52
|
-
href:
|
|
54
|
+
href: '',
|
|
53
55
|
};
|
|
54
56
|
});
|
|
55
57
|
}
|
|
@@ -63,10 +65,10 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
63
65
|
const discountPercent = getDiscountPercent(variationProduct.price, variationProduct.list_price);
|
|
64
66
|
const badges = [
|
|
65
67
|
...(variationProduct.field_news
|
|
66
|
-
? [{ text:
|
|
68
|
+
? [{ text: 'Novinka', color: 'bg-green-100 text-green-800' }]
|
|
67
69
|
: []),
|
|
68
70
|
...(variationProduct.field_aftersale
|
|
69
|
-
? [{ text:
|
|
71
|
+
? [{ text: 'Doprodej', color: 'bg-red-100 text-red-800' }]
|
|
70
72
|
: []),
|
|
71
73
|
];
|
|
72
74
|
return {
|
|
@@ -76,15 +78,15 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
76
78
|
variation_name: variationProduct.title,
|
|
77
79
|
sku: variationProduct.sku,
|
|
78
80
|
ean: variationProduct.field_ean,
|
|
79
|
-
description: defaultProduct.field_description?.processed ??
|
|
81
|
+
description: defaultProduct.field_description?.processed ?? '',
|
|
80
82
|
price: variationProduct?.list_price?.number
|
|
81
83
|
? variationProduct.list_price.number
|
|
82
|
-
: variationProduct.price?.number ?? 0,
|
|
84
|
+
: (variationProduct.price?.number ?? 0),
|
|
83
85
|
discountPercent,
|
|
84
86
|
product_id: defaultProduct.drupal_internal__product_id,
|
|
85
87
|
product_name: defaultProduct.title,
|
|
86
88
|
changed: variationProduct.changed,
|
|
87
|
-
category: defaultProduct.field_category ??
|
|
89
|
+
category: defaultProduct.field_category ?? '',
|
|
88
90
|
variation_images: mapImages(variationImages, ctx),
|
|
89
91
|
default_images: mapImages(defaultImages, ctx),
|
|
90
92
|
all_images: mapImages(allImages, ctx),
|
|
@@ -100,7 +102,9 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
100
102
|
...(variationProduct.packaging
|
|
101
103
|
? { packaging: variationProduct.packaging }
|
|
102
104
|
: {}),
|
|
103
|
-
...(variationProduct.country
|
|
105
|
+
...(variationProduct.country
|
|
106
|
+
? { country: variationProduct.country }
|
|
107
|
+
: {}),
|
|
104
108
|
...(variationProduct.weight &&
|
|
105
109
|
variationProduct.weight.number &&
|
|
106
110
|
variationProduct.weight.unit
|
|
@@ -123,7 +127,9 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
123
127
|
? { field_composition: variationProduct.field_composition }
|
|
124
128
|
: {}),
|
|
125
129
|
...(variationProduct.field_nutritional_info
|
|
126
|
-
? {
|
|
130
|
+
? {
|
|
131
|
+
field_nutritional_info: variationProduct.field_nutritional_info,
|
|
132
|
+
}
|
|
127
133
|
: {}),
|
|
128
134
|
...(variationProduct.field_species
|
|
129
135
|
? { field_species: variationProduct.field_species }
|
|
@@ -136,7 +142,8 @@ function mapProductBase(defaultProduct, variationProduct, ctx) {
|
|
|
136
142
|
field_manufacturer: {
|
|
137
143
|
name: defaultProduct.field_manufacturer.name,
|
|
138
144
|
status: defaultProduct.field_manufacturer.status,
|
|
139
|
-
description: defaultProduct.field_manufacturer.description
|
|
145
|
+
description: defaultProduct.field_manufacturer.description
|
|
146
|
+
.processed,
|
|
140
147
|
field_image: mapImages(defaultProduct.field_manufacturer.field_image, ctx),
|
|
141
148
|
},
|
|
142
149
|
}
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"name": "@q2devel/q2-core",
|
|
3
|
+
"version": "1.0.71",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"prepublishOnly": "npm version patch && npm run build",
|
|
16
|
+
"publish:patch": "npm publish",
|
|
17
|
+
"publish:minor": "npm version minor && npm run build && npm publish",
|
|
18
|
+
"publish:major": "npm version major && npm run build && npm publish"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/js-cookie": "^3.0.6",
|
|
26
|
+
"@types/jwt-decode": "^2.2.1",
|
|
27
|
+
"@types/react": "^19.1.7",
|
|
28
|
+
"@types/react-dom": "^19.1.6",
|
|
29
|
+
"typescript": "^5.8.3"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@tanstack/react-query": "^5.80.6",
|
|
33
|
+
"axios": "^1.9.0",
|
|
34
|
+
"drupal-jsonapi-params": "^2.3.2",
|
|
35
|
+
"js-cookie": "^3.0.5",
|
|
36
|
+
"jwt-decode": "^4.0.0",
|
|
37
|
+
"react": "^19.1.0"
|
|
10
38
|
}
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsc",
|
|
14
|
-
"prepare": "npm run build",
|
|
15
|
-
"prepublishOnly": "npm version patch && npm run build",
|
|
16
|
-
"publish:patch": "npm publish",
|
|
17
|
-
"publish:minor": "npm version minor && npm run build && npm publish",
|
|
18
|
-
"publish:major": "npm version major && npm run build && npm publish"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist"
|
|
22
|
-
],
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/js-cookie": "^3.0.6",
|
|
26
|
-
"@types/jwt-decode": "^2.2.1",
|
|
27
|
-
"@types/react": "^19.1.7",
|
|
28
|
-
"@types/react-dom": "^19.1.6",
|
|
29
|
-
"typescript": "^5.8.3"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@tanstack/react-query": "^5.80.6",
|
|
33
|
-
"axios": "^1.9.0",
|
|
34
|
-
"drupal-jsonapi-params": "^2.3.2",
|
|
35
|
-
"js-cookie": "^3.0.5",
|
|
36
|
-
"jwt-decode": "^4.0.0",
|
|
37
|
-
"react": "^19.1.0"
|
|
38
|
-
}
|
|
39
39
|
}
|