@propeller-commerce/propeller-v2-vue-ui 0.3.37 → 0.3.39
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/CHANGELOG.md +27 -0
- package/dist/index.cjs +41 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2041,6 +2041,7 @@ function useProductSearch(options) {
|
|
|
2041
2041
|
const currentSortField = ref(options.sortField?.value ?? ProductSortField.RELEVANCE);
|
|
2042
2042
|
const currentSortOrder = ref(options.sortOrder?.value ?? "DESC");
|
|
2043
2043
|
function filterByLanguage(products, lang) {
|
|
2044
|
+
if (!lang) return products;
|
|
2044
2045
|
return products.filter((p2) => {
|
|
2045
2046
|
const names = p2.names || p2.names || [];
|
|
2046
2047
|
if (!names || names.length === 0) return true;
|
|
@@ -2190,15 +2191,24 @@ function useProductSearch(options) {
|
|
|
2190
2191
|
if (!graphqlClient) return;
|
|
2191
2192
|
searchLoading.value = true;
|
|
2192
2193
|
try {
|
|
2193
|
-
const service = createServices(graphqlClient).product;
|
|
2194
2194
|
const lang = languageRef.value || "NL";
|
|
2195
|
+
const service = createServices(graphqlClient).category;
|
|
2196
|
+
const catId = configuration?.baseCategoryId ?? 0;
|
|
2197
|
+
if (!catId) {
|
|
2198
|
+
searchResults.value = [];
|
|
2199
|
+
searchItemsFound.value = 0;
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2195
2202
|
const searchOrderlistIds = options.orderlistIds?.value;
|
|
2196
2203
|
const orderlistScope = searchOrderlistIds && searchOrderlistIds.length > 0 ? {
|
|
2197
2204
|
applyOrderlists: options.applyOrderlists?.value !== false,
|
|
2198
2205
|
orderlistIds: searchOrderlistIds
|
|
2199
2206
|
} : { applyOrderlists: false };
|
|
2200
|
-
const
|
|
2201
|
-
|
|
2207
|
+
const user = userRef.value;
|
|
2208
|
+
const userId = user && "contactId" in user ? user.contactId : user && "customerId" in user ? user.customerId : void 0;
|
|
2209
|
+
const contactId = user && "contactId" in user ? user.contactId : void 0;
|
|
2210
|
+
const customerId = user && "customerId" in user ? user.customerId : void 0;
|
|
2211
|
+
const categoryProductSearchInput = {
|
|
2202
2212
|
language: lang,
|
|
2203
2213
|
page: 1,
|
|
2204
2214
|
offset: 10,
|
|
@@ -2208,8 +2218,8 @@ function useProductSearch(options) {
|
|
|
2208
2218
|
ProductStatus.T,
|
|
2209
2219
|
ProductStatus.S
|
|
2210
2220
|
],
|
|
2211
|
-
|
|
2212
|
-
|
|
2221
|
+
hidden: false,
|
|
2222
|
+
term,
|
|
2213
2223
|
searchFields: [
|
|
2214
2224
|
{
|
|
2215
2225
|
fieldNames: [
|
|
@@ -2236,16 +2246,34 @@ function useProductSearch(options) {
|
|
|
2236
2246
|
],
|
|
2237
2247
|
boost: 1
|
|
2238
2248
|
}
|
|
2239
|
-
]
|
|
2249
|
+
],
|
|
2250
|
+
sortInputs: [{ field: ProductSortField.RELEVANCE, order: SortOrder.DESC }],
|
|
2251
|
+
...companyIdRef.value && { companyId: companyIdRef.value },
|
|
2252
|
+
...userId !== void 0 && { userId },
|
|
2253
|
+
...orderlistScope
|
|
2254
|
+
};
|
|
2255
|
+
const priceCalculateProductInput = {
|
|
2256
|
+
taxZone,
|
|
2257
|
+
...companyIdRef.value && { companyId: companyIdRef.value },
|
|
2258
|
+
...contactId !== void 0 && { contactId },
|
|
2259
|
+
...customerId !== void 0 && { customerId }
|
|
2240
2260
|
};
|
|
2241
2261
|
const variables = {
|
|
2242
|
-
|
|
2262
|
+
categoryId: catId,
|
|
2243
2263
|
language: lang,
|
|
2264
|
+
categoryProductSearchInput,
|
|
2265
|
+
priceCalculateProductInput,
|
|
2266
|
+
imageSearchFilters: configuration?.imageSearchFiltersGrid,
|
|
2244
2267
|
imageVariantFilters: configuration?.imageVariantFiltersMedium
|
|
2245
2268
|
};
|
|
2246
|
-
const
|
|
2247
|
-
|
|
2248
|
-
|
|
2269
|
+
const response = await service.getCategory(variables);
|
|
2270
|
+
const productsResponse = response?.products;
|
|
2271
|
+
const rawItems = productsResponse?.items ?? [];
|
|
2272
|
+
const items = filterByLanguage(rawItems, lang);
|
|
2273
|
+
const untranslated = rawItems.length - items.length;
|
|
2274
|
+
const apiTotal = productsResponse?.itemsFound ?? rawItems.length;
|
|
2275
|
+
searchResults.value = items;
|
|
2276
|
+
searchItemsFound.value = Math.max(0, apiTotal - untranslated);
|
|
2249
2277
|
} catch {
|
|
2250
2278
|
searchResults.value = [];
|
|
2251
2279
|
searchItemsFound.value = 0;
|
|
@@ -20081,9 +20109,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
20081
20109
|
const url = typeof builder === "function" ? builder(item, infra.language) : isCluster ? "/cluster/" + id + "/" + slug : "/product/" + id + "/" + slug;
|
|
20082
20110
|
const priceNet = displayItem?.price?.net || 0;
|
|
20083
20111
|
const priceGross = displayItem?.price?.gross || 0;
|
|
20112
|
+
const lang = infra.language;
|
|
20113
|
+
const localizedName = lang && item.names?.find((n) => n.language === lang)?.value || item.names?.[0]?.value || "Product";
|
|
20084
20114
|
return {
|
|
20085
20115
|
id,
|
|
20086
|
-
name:
|
|
20116
|
+
name: localizedName,
|
|
20087
20117
|
sku: item.sku || displayItem?.sku || "",
|
|
20088
20118
|
// `price` stays gross for back-compat; the row picks net/gross per toggle.
|
|
20089
20119
|
price: priceGross,
|