@tapcart/mobile-components 0.7.11 → 0.7.12
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGtF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,CAAC;IACjF,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGtF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,CAAC;IACjF,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,gBAAgB,GAAG,IAAI,CAAA;IAClE,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,gBAAgB,CA2D1E;AAED,KAAK,wBAAwB,GAAG,gBAAgB,GAAG;IACjD,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CACtC,CAAA;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,wBAAwB,CAyI1F"}
|
|
@@ -6,7 +6,7 @@ import { useInView } from 'react-intersection-observer';
|
|
|
6
6
|
export function useReviews(props) {
|
|
7
7
|
let url = null;
|
|
8
8
|
if (props) {
|
|
9
|
-
const { baseURL, productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, page } = props;
|
|
9
|
+
const { baseURL, productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, page, limit } = props;
|
|
10
10
|
let queryParams = new URLSearchParams();
|
|
11
11
|
if (productId.length > 0) {
|
|
12
12
|
queryParams.set("id", productId);
|
|
@@ -36,6 +36,9 @@ export function useReviews(props) {
|
|
|
36
36
|
if (page) {
|
|
37
37
|
queryParams.set("page", String(page));
|
|
38
38
|
}
|
|
39
|
+
if (limit) {
|
|
40
|
+
queryParams.set("limit", String(limit));
|
|
41
|
+
}
|
|
39
42
|
if (dataType === null || productId === null || productId.length === 0) {
|
|
40
43
|
url = null;
|
|
41
44
|
}
|
|
@@ -58,7 +61,7 @@ export function useReviewsInfinite(props) {
|
|
|
58
61
|
let baseURL = "";
|
|
59
62
|
let queryParams = new URLSearchParams();
|
|
60
63
|
if (props) {
|
|
61
|
-
const { productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage } = props;
|
|
64
|
+
const { productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, limit } = props;
|
|
62
65
|
baseURL = props.baseURL;
|
|
63
66
|
if (productId.length > 0) {
|
|
64
67
|
queryParams.set("id", productId);
|
|
@@ -85,6 +88,9 @@ export function useReviewsInfinite(props) {
|
|
|
85
88
|
if (perPage) {
|
|
86
89
|
queryParams.set("perPage", String(perPage));
|
|
87
90
|
}
|
|
91
|
+
if (limit) {
|
|
92
|
+
queryParams.set("limit", String(limit));
|
|
93
|
+
}
|
|
88
94
|
if (dataType === null || productId === null || productId.length === 0) {
|
|
89
95
|
url = null;
|
|
90
96
|
}
|
|
@@ -94,12 +100,12 @@ export function useReviewsInfinite(props) {
|
|
|
94
100
|
}
|
|
95
101
|
const isEndReached = useRef(false);
|
|
96
102
|
const getKey = (pageIndex, previousPageData) => {
|
|
97
|
-
var _a, _b;
|
|
103
|
+
var _a, _b, _c;
|
|
104
|
+
const dataType = queryParams.get("dataType") === "null" ? null : queryParams.get("dataType");
|
|
105
|
+
if (dataType == null) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
98
108
|
if ((props === null || props === void 0 ? void 0 : props.provider) === "yotpo") {
|
|
99
|
-
const dataType = queryParams.get("dataType") === "null" ? null : queryParams.get("dataType");
|
|
100
|
-
if (dataType == null) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
109
|
if (previousPageData && previousPageData.pagination) {
|
|
104
110
|
const { perPage, total } = previousPageData.pagination;
|
|
105
111
|
isEndReached.current = (((pageIndex + 1) * perPage) >= total);
|
|
@@ -115,6 +121,16 @@ export function useReviewsInfinite(props) {
|
|
|
115
121
|
}
|
|
116
122
|
return `${baseURL}/reviews/by-id?${queryParams.toString()}&nextUrl=${((_b = previousPageData === null || previousPageData === void 0 ? void 0 : previousPageData.pagination) === null || _b === void 0 ? void 0 : _b.nextUrl) || null}`;
|
|
117
123
|
}
|
|
124
|
+
if ((props === null || props === void 0 ? void 0 : props.provider) === "stamped") {
|
|
125
|
+
if (pageIndex === 0)
|
|
126
|
+
return `${baseURL}/reviews/by-id?${queryParams.toString()}`;
|
|
127
|
+
const totalPages = (_c = previousPageData === null || previousPageData === void 0 ? void 0 : previousPageData.pagination) === null || _c === void 0 ? void 0 : _c.totalPages;
|
|
128
|
+
if (totalPages && (pageIndex + 1) >= totalPages) {
|
|
129
|
+
isEndReached.current = true;
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return `${baseURL}/reviews/by-id?${queryParams.toString()}&page=${pageIndex + 1}`;
|
|
133
|
+
}
|
|
118
134
|
};
|
|
119
135
|
const fetcher = (props === null || props === void 0 ? void 0 : props.fetcher) || ((url) => fetch(url).then((res) => res.json()));
|
|
120
136
|
const { data: dataInfinite, error: errorInfinite, size, setSize, isLoading, isValidating, } = useSWRInfinite(getKey, fetcher);
|