@propeller-commerce/propeller-v2-vue-ui 0.3.37 → 0.3.38

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/index.js CHANGED
@@ -2190,15 +2190,24 @@ function useProductSearch(options) {
2190
2190
  if (!graphqlClient) return;
2191
2191
  searchLoading.value = true;
2192
2192
  try {
2193
- const service = createServices(graphqlClient).product;
2194
2193
  const lang = languageRef.value || "NL";
2194
+ const service = createServices(graphqlClient).category;
2195
+ const catId = configuration?.baseCategoryId ?? 0;
2196
+ if (!catId) {
2197
+ searchResults.value = [];
2198
+ searchItemsFound.value = 0;
2199
+ return;
2200
+ }
2195
2201
  const searchOrderlistIds = options.orderlistIds?.value;
2196
2202
  const orderlistScope = searchOrderlistIds && searchOrderlistIds.length > 0 ? {
2197
2203
  applyOrderlists: options.applyOrderlists?.value !== false,
2198
2204
  orderlistIds: searchOrderlistIds
2199
2205
  } : { applyOrderlists: false };
2200
- const input = {
2201
- term,
2206
+ const user = userRef.value;
2207
+ const userId = user && "contactId" in user ? user.contactId : user && "customerId" in user ? user.customerId : void 0;
2208
+ const contactId = user && "contactId" in user ? user.contactId : void 0;
2209
+ const customerId = user && "customerId" in user ? user.customerId : void 0;
2210
+ const categoryProductSearchInput = {
2202
2211
  language: lang,
2203
2212
  page: 1,
2204
2213
  offset: 10,
@@ -2208,8 +2217,8 @@ function useProductSearch(options) {
2208
2217
  ProductStatus.T,
2209
2218
  ProductStatus.S
2210
2219
  ],
2211
- ...orderlistScope,
2212
- sortInputs: [{ field: ProductSortField.RELEVANCE, order: SortOrder.DESC }],
2220
+ hidden: false,
2221
+ term,
2213
2222
  searchFields: [
2214
2223
  {
2215
2224
  fieldNames: [
@@ -2236,16 +2245,30 @@ function useProductSearch(options) {
2236
2245
  ],
2237
2246
  boost: 1
2238
2247
  }
2239
- ]
2248
+ ],
2249
+ sortInputs: [{ field: ProductSortField.RELEVANCE, order: SortOrder.DESC }],
2250
+ ...companyIdRef.value && { companyId: companyIdRef.value },
2251
+ ...userId !== void 0 && { userId },
2252
+ ...orderlistScope
2253
+ };
2254
+ const priceCalculateProductInput = {
2255
+ taxZone,
2256
+ ...companyIdRef.value && { companyId: companyIdRef.value },
2257
+ ...contactId !== void 0 && { contactId },
2258
+ ...customerId !== void 0 && { customerId }
2240
2259
  };
2241
2260
  const variables = {
2242
- input,
2261
+ categoryId: catId,
2243
2262
  language: lang,
2263
+ categoryProductSearchInput,
2264
+ priceCalculateProductInput,
2265
+ imageSearchFilters: configuration?.imageSearchFiltersGrid,
2244
2266
  imageVariantFilters: configuration?.imageVariantFiltersMedium
2245
2267
  };
2246
- const result = await service.getProducts(variables);
2247
- searchResults.value = result?.items ?? [];
2248
- searchItemsFound.value = result?.itemsFound ?? searchResults.value.length;
2268
+ const response = await service.getCategory(variables);
2269
+ const productsResponse = response?.products;
2270
+ searchResults.value = productsResponse?.items ?? [];
2271
+ searchItemsFound.value = productsResponse?.itemsFound ?? searchResults.value.length;
2249
2272
  } catch {
2250
2273
  searchResults.value = [];
2251
2274
  searchItemsFound.value = 0;