@sledge-app/react-instant-search 0.0.95 → 0.0.97
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/components/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/sledge-react-instant-search.cjs +1 -1
- package/dist/sledge-react-instant-search.cjs.map +1 -1
- package/dist/sledge-react-instant-search.js +3 -73
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -719,29 +719,6 @@ const BadgeHeaderMenu = (props) => {
|
|
|
719
719
|
!isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
|
|
720
720
|
] });
|
|
721
721
|
};
|
|
722
|
-
const getWishlist = async (query, token) => {
|
|
723
|
-
const { page, limit, sort, keyword, shareId } = query || {};
|
|
724
|
-
let sledgeAuthApp = token || localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
725
|
-
let queryParams = "?" + new URLSearchParams({
|
|
726
|
-
page: page || "",
|
|
727
|
-
limit: limit || "",
|
|
728
|
-
sort: sort || "",
|
|
729
|
-
keyword: keyword || "",
|
|
730
|
-
share_id: shareId || ""
|
|
731
|
-
}).toString();
|
|
732
|
-
var myHeaders = new Headers();
|
|
733
|
-
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
734
|
-
var requestOptions = {
|
|
735
|
-
method: "GET",
|
|
736
|
-
headers: myHeaders,
|
|
737
|
-
redirect: "follow"
|
|
738
|
-
};
|
|
739
|
-
return await fetch(`${API_URL}/wishlist${queryParams}`, requestOptions).then((response) => response.json()).then((result) => {
|
|
740
|
-
return result;
|
|
741
|
-
}).catch(() => {
|
|
742
|
-
return;
|
|
743
|
-
});
|
|
744
|
-
};
|
|
745
722
|
const addWishlist = async (data) => {
|
|
746
723
|
const { productId, productVariantId, productName, productVendor, productSku, productVariantName, productLink, productImage, productCurrency, productPrice } = data;
|
|
747
724
|
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
@@ -1560,22 +1537,6 @@ const getReviewInfo = async (id) => {
|
|
|
1560
1537
|
return;
|
|
1561
1538
|
});
|
|
1562
1539
|
};
|
|
1563
|
-
const getProductsReviewInfo = async (ids, token) => {
|
|
1564
|
-
let convertIds = ids.map((v) => sanitizeDataId(v));
|
|
1565
|
-
let sledgeAuthApp = token || localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
1566
|
-
var myHeaders = new Headers();
|
|
1567
|
-
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
1568
|
-
var requestOptions = {
|
|
1569
|
-
method: "GET",
|
|
1570
|
-
headers: myHeaders,
|
|
1571
|
-
redirect: "follow"
|
|
1572
|
-
};
|
|
1573
|
-
return await fetch(`${API_URL}/review/info/ids/${convertIds.join(",")}`, requestOptions).then((response) => response.json()).then((result) => {
|
|
1574
|
-
return result;
|
|
1575
|
-
}).catch(() => {
|
|
1576
|
-
return;
|
|
1577
|
-
});
|
|
1578
|
-
};
|
|
1579
1540
|
const Rating = (props) => {
|
|
1580
1541
|
var _a, _b;
|
|
1581
1542
|
const { total, average, size = "md", params, withSkeletonLoading = true, withTotal = true, isScrollToElementWidget = true, data: propsData, sledgeSettings } = props;
|
|
@@ -2213,7 +2174,6 @@ const ProductGrid = ({
|
|
|
2213
2174
|
onAfterRenderProduct && onAfterRenderProduct("success");
|
|
2214
2175
|
}, []);
|
|
2215
2176
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__product-grid ${className}`, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
|
|
2216
|
-
var _a, _b, _c;
|
|
2217
2177
|
const { product, variants } = item || {};
|
|
2218
2178
|
const { id, title, image, url, vendor = "", currency } = product || {};
|
|
2219
2179
|
const { id: variant_id = "", title: variant_title = "", price = "", sku = "" } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
|
|
@@ -2229,11 +2189,7 @@ const ProductGrid = ({
|
|
|
2229
2189
|
...variant,
|
|
2230
2190
|
is_out_of_stock: Object.hasOwn(variants[index2], "inventory_quantity") ? !inventory_quantity : false
|
|
2231
2191
|
};
|
|
2232
|
-
})
|
|
2233
|
-
review: {
|
|
2234
|
-
total: ((_a = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _a.review_count) ? dataReviews == null ? void 0 : dataReviews[id].review_count : 0,
|
|
2235
|
-
average: ((_c = (_b = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _b.rating) == null ? void 0 : _c.average) ? dataReviews == null ? void 0 : dataReviews[id].rating.average : 0
|
|
2236
|
-
}
|
|
2192
|
+
})
|
|
2237
2193
|
}
|
|
2238
2194
|
},
|
|
2239
2195
|
showPopupComponent,
|
|
@@ -2760,19 +2716,6 @@ const SearchIconWidget = (props) => {
|
|
|
2760
2716
|
};
|
|
2761
2717
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__icon-widget", onClick: handleShowWidget, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { ...sizing, color: "currentColor" }) });
|
|
2762
2718
|
};
|
|
2763
|
-
const wishlistCheck = async (session, productIds = []) => {
|
|
2764
|
-
let wishlisted = await getWishlist({ limit: 1e3 }, session.token);
|
|
2765
|
-
wishlisted = (wishlisted == null ? void 0 : wishlisted.data) || [];
|
|
2766
|
-
let result = {};
|
|
2767
|
-
for (let id of productIds) {
|
|
2768
|
-
const exist = wishlisted.find((f) => {
|
|
2769
|
-
var _a, _b;
|
|
2770
|
-
return ((_b = (_a = f.product) == null ? void 0 : _a.id) == null ? void 0 : _b.toString()) === id.toString();
|
|
2771
|
-
});
|
|
2772
|
-
result[id] = !!exist;
|
|
2773
|
-
}
|
|
2774
|
-
return result;
|
|
2775
|
-
};
|
|
2776
2719
|
const OtherIndexLists = ({
|
|
2777
2720
|
listsComponent,
|
|
2778
2721
|
name,
|
|
@@ -2844,7 +2787,6 @@ const SearchIconWidgetPopup = () => {
|
|
|
2844
2787
|
const [keyword, setKeyword] = React__default.useState("");
|
|
2845
2788
|
const [searchResultProduct, setSearchResultProduct] = React__default.useState([]);
|
|
2846
2789
|
const [searchResultOther, setSearchResultOther] = React__default.useState([]);
|
|
2847
|
-
const [dataReviews, setDataReviews] = React__default.useState([]);
|
|
2848
2790
|
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
2849
2791
|
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
2850
2792
|
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
@@ -2866,7 +2808,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2866
2808
|
const searchFieldRef = React__default.useRef(null);
|
|
2867
2809
|
const previousState = usePrevious({ keyword });
|
|
2868
2810
|
const handleMultiSearch = async (data, onSearch = false) => {
|
|
2869
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2
|
|
2811
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
|
|
2870
2812
|
setIsLoading(true);
|
|
2871
2813
|
const { tabs, suffix_index_product, hidden_tags, display, show_out_of_stock } = data;
|
|
2872
2814
|
const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
|
|
@@ -2915,16 +2857,6 @@ const SearchIconWidgetPopup = () => {
|
|
|
2915
2857
|
!keyword.length && Object.keys(suggestion).length && ((_f2 = (_e2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _e2.products) == null ? void 0 : _f2.active) && ((_i2 = (_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.list) == null ? void 0 : _i2.length)
|
|
2916
2858
|
);
|
|
2917
2859
|
let dataSearchResultProduct = isPriorityZeroCharacter ? (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list : getValueSearchResultProduct;
|
|
2918
|
-
let searchResultProductIds = dataSearchResultProduct.map(({ id }) => id);
|
|
2919
|
-
await wishlistCheck(
|
|
2920
|
-
{
|
|
2921
|
-
token: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP)) || null
|
|
2922
|
-
},
|
|
2923
|
-
searchResultProductIds
|
|
2924
|
-
);
|
|
2925
|
-
let valueDataReviews = await getProductsReviewInfo(searchResultProductIds);
|
|
2926
|
-
if (((_l2 = valueDataReviews == null ? void 0 : valueDataReviews.status) == null ? void 0 : _l2.code) === 200)
|
|
2927
|
-
setDataReviews(valueDataReviews == null ? void 0 : valueDataReviews.data);
|
|
2928
2860
|
setSearchResultProduct(dataSearchResultProduct);
|
|
2929
2861
|
setSearchResultOther(valueSearchResultOther);
|
|
2930
2862
|
setSuggestionIndex(valueSuggestionIndex);
|
|
@@ -2981,7 +2913,6 @@ const SearchIconWidgetPopup = () => {
|
|
|
2981
2913
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
2982
2914
|
}, [isRenderAppInstantSearch]);
|
|
2983
2915
|
React__default.useEffect(() => {
|
|
2984
|
-
console.log("keyword SearchIconWidgetPopup", keyword);
|
|
2985
2916
|
showInfo ? document.body.classList.add("sledge__open-popup-state") : document.body.classList.remove("sledge__open-popup-state");
|
|
2986
2917
|
}, [showInfo]);
|
|
2987
2918
|
React__default.useEffect(() => {
|
|
@@ -3106,8 +3037,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
3106
3037
|
onAfterRemoveWishlist: handleFunctions.onAfterRemoveWishlist,
|
|
3107
3038
|
onAfterRenderProduct: handleFunctions.onAfterRenderProduct,
|
|
3108
3039
|
showPopupComponent: showInfo,
|
|
3109
|
-
setShowPopupComponent: setShowInfo
|
|
3110
|
-
dataReviews
|
|
3040
|
+
setShowPopupComponent: setShowInfo
|
|
3111
3041
|
}
|
|
3112
3042
|
) }) : Object.keys(suggestionSettings).length && ((_k = (_j = suggestionSettings[suggestionIndex]) == null ? void 0 : _j.products) == null ? void 0 : _k.active) && ((_n = (_m = (_l = suggestionSettings[suggestionIndex]) == null ? void 0 : _l.products) == null ? void 0 : _m.list) == null ? void 0 : _n.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3113
3043
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-product-suggestion-no-result-text", children: [
|