@propeller-commerce/propeller-v2-react-ui 0.4.27 → 0.4.28

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
@@ -2344,13 +2344,21 @@ function useProductSearch(options) {
2344
2344
  if (!graphqlClient) return;
2345
2345
  setSearchLoading(true);
2346
2346
  try {
2347
- const service = createServices(graphqlClient).product;
2347
+ const service = createServices(graphqlClient).category;
2348
+ const catId = configuration?.baseCategoryId ?? 0;
2349
+ if (!catId) {
2350
+ setSearchResults([]);
2351
+ setSearchItemsFound(0);
2352
+ return;
2353
+ }
2348
2354
  const orderlistScope = options.orderlistIds && options.orderlistIds.length > 0 ? {
2349
2355
  applyOrderlists: options.applyOrderlists !== false,
2350
2356
  orderlistIds: options.orderlistIds
2351
2357
  } : { applyOrderlists: false };
2352
- const input = {
2353
- term,
2358
+ const userId = options.user && "contactId" in options.user ? options.user.contactId : options.user && "customerId" in options.user ? options.user.customerId : void 0;
2359
+ const contactId = options.user && "contactId" in options.user ? options.user.contactId : void 0;
2360
+ const customerId = options.user && "customerId" in options.user ? options.user.customerId : void 0;
2361
+ const categoryProductSearchInput = {
2354
2362
  language,
2355
2363
  page: 1,
2356
2364
  offset: 10,
@@ -2360,8 +2368,8 @@ function useProductSearch(options) {
2360
2368
  ProductStatus.T,
2361
2369
  ProductStatus.S
2362
2370
  ],
2363
- ...orderlistScope,
2364
- sortInputs: [{ field: ProductSortField.RELEVANCE, order: SortOrder.DESC }],
2371
+ hidden: false,
2372
+ term,
2365
2373
  searchFields: [
2366
2374
  {
2367
2375
  fieldNames: [
@@ -2388,17 +2396,31 @@ function useProductSearch(options) {
2388
2396
  ],
2389
2397
  boost: 1
2390
2398
  }
2391
- ]
2399
+ ],
2400
+ sortInputs: [{ field: ProductSortField.RELEVANCE, order: SortOrder.DESC }],
2401
+ ...options.companyId && { companyId: options.companyId },
2402
+ ...userId !== void 0 && { userId },
2403
+ ...orderlistScope
2404
+ };
2405
+ const priceCalculateProductInput = {
2406
+ taxZone,
2407
+ ...options.companyId && { companyId: options.companyId },
2408
+ ...contactId !== void 0 && { contactId },
2409
+ ...customerId !== void 0 && { customerId }
2392
2410
  };
2393
2411
  const variables = {
2394
- input,
2412
+ categoryId: catId,
2395
2413
  language,
2414
+ categoryProductSearchInput,
2415
+ priceCalculateProductInput,
2416
+ imageSearchFilters: configuration?.imageSearchFiltersGrid,
2396
2417
  imageVariantFilters: configuration?.imageVariantFiltersMedium
2397
2418
  };
2398
- const result = await service.getProducts(variables);
2399
- const items = result?.items ?? [];
2419
+ const response = await service.getCategory(variables);
2420
+ const productsResponse = response?.products;
2421
+ const items = productsResponse?.items ?? [];
2400
2422
  setSearchResults(items);
2401
- setSearchItemsFound(result?.itemsFound ?? items.length);
2423
+ setSearchItemsFound(productsResponse?.itemsFound ?? items.length);
2402
2424
  } catch {
2403
2425
  setSearchResults([]);
2404
2426
  setSearchItemsFound(0);