@sledge-app/react-instant-search 0.0.5 → 0.0.7
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.
|
@@ -1165,6 +1165,7 @@ const Rating = (props) => {
|
|
|
1165
1165
|
const [totalReview, setTotalReview] = React__default.useState(0);
|
|
1166
1166
|
const [averageReview, setAverageReview] = React__default.useState("0");
|
|
1167
1167
|
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
1168
|
+
const previousState = usePrevious({ productId });
|
|
1168
1169
|
const { fill_color, outline_color } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.rating) || {};
|
|
1169
1170
|
const handleProductRatingInfo = async () => {
|
|
1170
1171
|
var _a2;
|
|
@@ -1188,6 +1189,7 @@ const Rating = (props) => {
|
|
|
1188
1189
|
setTotalReview(valueTotalReview);
|
|
1189
1190
|
setAverageReview(valueAverageReview);
|
|
1190
1191
|
setIsLoading(false);
|
|
1192
|
+
setIsFirstLoading(false);
|
|
1191
1193
|
}
|
|
1192
1194
|
}
|
|
1193
1195
|
};
|
|
@@ -1225,10 +1227,10 @@ const Rating = (props) => {
|
|
|
1225
1227
|
height: 28.8
|
|
1226
1228
|
});
|
|
1227
1229
|
}
|
|
1230
|
+
let isProductIdChanged = Boolean(previousState && (previousState == null ? void 0 : previousState.productId) !== productId);
|
|
1231
|
+
if (isProductIdChanged)
|
|
1232
|
+
setIsFirstLoading(true);
|
|
1228
1233
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || "");
|
|
1229
|
-
setTimeout(() => {
|
|
1230
|
-
setIsFirstLoading(false);
|
|
1231
|
-
}, 1300);
|
|
1232
1234
|
}, [isRenderApp, productId]);
|
|
1233
1235
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__rating", children: isFirstLoading && withSkeletonLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "230px", height: "28px", color: "grey-100", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1234
1236
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", style: { display: "none" }, id: "sledge-product-review-rating-icon-svg-store", children: [
|
|
@@ -1405,6 +1407,7 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1405
1407
|
1: 0
|
|
1406
1408
|
});
|
|
1407
1409
|
const [averageReview, setAverageReview] = React__default.useState("0");
|
|
1410
|
+
const previousState = usePrevious({ productId });
|
|
1408
1411
|
const handleProductReviewInfo = async () => {
|
|
1409
1412
|
var _a2;
|
|
1410
1413
|
let response;
|
|
@@ -1444,8 +1447,11 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1444
1447
|
handleProductReviewInfo();
|
|
1445
1448
|
};
|
|
1446
1449
|
}
|
|
1450
|
+
let isProductIdChanged = Boolean(previousState && (previousState == null ? void 0 : previousState.productId) !== productId);
|
|
1451
|
+
if (isProductIdChanged)
|
|
1452
|
+
setIsFirstLoading(true);
|
|
1447
1453
|
handleProductReviewInfo();
|
|
1448
|
-
}, [isOpen]);
|
|
1454
|
+
}, [isOpen, productId]);
|
|
1449
1455
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "630px", height: "42px", color: "grey-100", rounded: "md", animationDuration: "5s" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1450
1456
|
Popover,
|
|
1451
1457
|
{
|