@sledge-app/react-instant-search 1.0.0 → 1.0.2

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.
@@ -5,8 +5,8 @@ import "react-dom";
5
5
  const ProductFilterWidget = (props) => {
6
6
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SearchResultWidget, { layoutType: "product-filter", ...props });
7
7
  };
8
- const API_URL = "https://sledge-api-preprod.offstack.io";
9
- const INSTANT_SEARCH_ENGINE_URL = "https://instant-search-engine.offstack.io";
8
+ const API_URL = "https://api.sledge-app.com";
9
+ const INSTANT_SEARCH_ENGINE_URL = "https://instant-search-engine.sledge-app.com";
10
10
  const SELECTOR_ATTRIBUTE_KEY = "data-component";
11
11
  const DATASET_ATTRIBUTE_KEY = {
12
12
  GLOBAL: {
@@ -2289,17 +2289,6 @@ const ProductGrid = ({
2289
2289
  display_button_add_to_cart_style = {}
2290
2290
  } = setting || {};
2291
2291
  const [clickedAddToCartId, setClickedAddToCartId] = React__default.useState(null);
2292
- const addToCartTrigger$2 = sourceApp ? async (productId) => {
2293
- if (sourceApp === "wishlist") {
2294
- await addToCartTrigger$1({
2295
- productId
2296
- });
2297
- } else if (sourceApp === "instant-search") {
2298
- await addToCartTrigger({
2299
- productId
2300
- });
2301
- }
2302
- } : null;
2303
2292
  const handleAddToCart = async (data2) => {
2304
2293
  var _a;
2305
2294
  const { id, quantity } = data2;
@@ -2311,7 +2300,15 @@ const ProductGrid = ({
2311
2300
  }
2312
2301
  ]);
2313
2302
  if ((_a = resShopifyAddToCart == null ? void 0 : resShopifyAddToCart.items) == null ? void 0 : _a.length) {
2314
- addToCartTrigger$2 && addToCartTrigger$2(id);
2303
+ if (sourceApp === "wishlist") {
2304
+ await addToCartTrigger$1({
2305
+ productId: id
2306
+ });
2307
+ } else if (sourceApp === "instant-search") {
2308
+ await addToCartTrigger({
2309
+ productId: id
2310
+ });
2311
+ }
2315
2312
  setClickedAddToCartId(null);
2316
2313
  onAfterAddToCart && onAfterAddToCart("success");
2317
2314
  if (redirect_add_to_cart) {
@@ -2349,6 +2346,23 @@ const ProductGrid = ({
2349
2346
  const { id: variant_id = "", title: variant_title = "", price = "", sku = "" } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
2350
2347
  let isLoadingAddToCart = clickedAddToCartId == variant_id;
2351
2348
  let isOutOfStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? !variants[0].inventory_quantity && showOptionOutOfStock : false;
2349
+ const addToCartTrigger$2 = async () => {
2350
+ if (sourceApp === "wishlist") {
2351
+ await addToCartTrigger$1({
2352
+ productId: id
2353
+ });
2354
+ } else if (sourceApp === "instant-search") {
2355
+ await addToCartTrigger({
2356
+ productId: id
2357
+ });
2358
+ }
2359
+ };
2360
+ const productClickTrigger$1 = async () => {
2361
+ if (sourceApp === "instant-search")
2362
+ productClickTrigger({
2363
+ productId: id
2364
+ });
2365
+ };
2352
2366
  const getCards = cards ? cards({
2353
2367
  product: {
2354
2368
  ...product,
@@ -2370,7 +2384,8 @@ const ProductGrid = ({
2370
2384
  },
2371
2385
  showPopupComponent,
2372
2386
  setShowPopupComponent,
2373
- ...addToCartTrigger$2 ? addToCartTrigger$2 : {}
2387
+ addToCartTrigger: addToCartTrigger$2,
2388
+ productClickTrigger: productClickTrigger$1
2374
2389
  }) : null;
2375
2390
  return cards ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: getCards } }) : getCards }, index) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
2376
2391
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [