@tapcart/mobile-components 0.7.23 → 0.7.25
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-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAKtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,
|
|
1
|
+
{"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAKtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,uBAiC3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -7,27 +7,24 @@ const constructURL = (apiURL) => {
|
|
|
7
7
|
};
|
|
8
8
|
const useRecommendations = ({ queryVariables, apiURL }) => {
|
|
9
9
|
const searchParams = useSearchParams();
|
|
10
|
-
const recommendation = searchParams.get('recommendation');
|
|
11
|
-
const
|
|
12
|
-
//To remove when pageState data is available to block tempaltes
|
|
10
|
+
const recommendation = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get('recommendation')) || "*";
|
|
11
|
+
const isBestSeller = recommendation === "*";
|
|
13
12
|
const fetcher = (body) => fetch(constructURL(apiURL), {
|
|
14
13
|
method: "POST",
|
|
15
14
|
body: JSON.stringify(body),
|
|
16
15
|
}).then((res) => res.json());
|
|
17
|
-
const { data, error, isLoading } = useSWR(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
: null, fetcher, {
|
|
16
|
+
const { data, error, isLoading } = useSWR({
|
|
17
|
+
appId: queryVariables.appId,
|
|
18
|
+
query: recommendation,
|
|
19
|
+
language: queryVariables.language,
|
|
20
|
+
}, fetcher, {
|
|
24
21
|
revalidateOnFocus: false,
|
|
25
22
|
revalidateOnReconnect: false,
|
|
26
23
|
});
|
|
27
24
|
return {
|
|
28
25
|
products: data === null || data === void 0 ? void 0 : data.products,
|
|
29
26
|
collections: data === null || data === void 0 ? void 0 : data.collections,
|
|
30
|
-
searches: data === null || data === void 0 ? void 0 : data.searches,
|
|
27
|
+
searches: isBestSeller ? [] : data === null || data === void 0 ? void 0 : data.searches,
|
|
31
28
|
isLoading: isLoading,
|
|
32
29
|
error: error
|
|
33
30
|
};
|