@sonic-equipment/ui 0.0.48 → 0.0.49
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/config.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { SearchClient } from 'algoliasearch';
|
|
3
3
|
import { Autocomplete, GlobalSearchContextValue } from 'global-search/types';
|
|
4
4
|
export declare const GlobalSearchContext: React.Context<GlobalSearchContextValue | null>;
|
|
5
|
-
export declare function AlgoliaSearchProvider({ children, searchClient, }: {
|
|
5
|
+
export declare function AlgoliaSearchProvider({ children, searchClient: _searchClient, }: {
|
|
6
6
|
children?: ReactNode | ((autocomplete: Autocomplete) => ReactNode);
|
|
7
|
-
searchClient
|
|
7
|
+
searchClient?: SearchClient;
|
|
8
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { SearchClient } from 'algoliasearch';
|
|
3
3
|
interface GlobalSearchProps {
|
|
4
4
|
children: ReactNode;
|
|
5
|
-
searchClient
|
|
5
|
+
searchClient?: SearchClient;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Global search using algolia autocomplete with a custom renderer
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ interface Config {
|
|
|
18
18
|
ALGOLIA_HOST: string;
|
|
19
19
|
ALGOLIA_PROXY_HOST: string;
|
|
20
20
|
BFF_API_URL: string;
|
|
21
|
+
PROXY_API_URL: string;
|
|
21
22
|
SHOP_API_URL: string;
|
|
22
23
|
}
|
|
23
24
|
declare const configPerEnvironment: Record<Environment, Config>;
|
|
@@ -4066,7 +4067,7 @@ declare function AlgoliaSortBy(): react_jsx_runtime.JSX.Element | null;
|
|
|
4066
4067
|
|
|
4067
4068
|
interface GlobalSearchProps {
|
|
4068
4069
|
children: ReactNode;
|
|
4069
|
-
searchClient
|
|
4070
|
+
searchClient?: SearchClient;
|
|
4070
4071
|
}
|
|
4071
4072
|
/**
|
|
4072
4073
|
* Global search using algolia autocomplete with a custom renderer
|
package/dist/index.js
CHANGED
|
@@ -53,8 +53,9 @@ const configPerEnvironment = {
|
|
|
53
53
|
ALGOLIA_API_KEY: 'e31a3a53449eceb4d0f9273b9bcd9759',
|
|
54
54
|
ALGOLIA_APP_ID: '14CUFCVMAD',
|
|
55
55
|
ALGOLIA_HOST: 'bff.shop.sonic-equipment.com',
|
|
56
|
-
ALGOLIA_PROXY_HOST: '
|
|
56
|
+
ALGOLIA_PROXY_HOST: 'sonicequipment.commerce.insitesandbox.com',
|
|
57
57
|
BFF_API_URL: 'https://bff.shop.sonic-equipment.com',
|
|
58
|
+
PROXY_API_URL: 'https://shop.sonic-equipment.com/bff',
|
|
58
59
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
59
60
|
SHOP_API_URL: '',
|
|
60
61
|
},
|
|
@@ -62,8 +63,9 @@ const configPerEnvironment = {
|
|
|
62
63
|
ALGOLIA_API_KEY: 'e0edf30798a6b2e4e44fd25f0f2f9646',
|
|
63
64
|
ALGOLIA_APP_ID: 'testing9VXJ0U4GSV',
|
|
64
65
|
ALGOLIA_HOST: 'test-bff.shop.sonic-equipment.com',
|
|
65
|
-
ALGOLIA_PROXY_HOST: '
|
|
66
|
+
ALGOLIA_PROXY_HOST: 'sonicequipment.commerce.insitesandbox.com',
|
|
66
67
|
BFF_API_URL: 'https://test-bff.shop.sonic-equipment.com',
|
|
68
|
+
PROXY_API_URL: 'https://sonicequipment.commerce.insitesandbox.com/bff',
|
|
67
69
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
68
70
|
SHOP_API_URL: '',
|
|
69
71
|
},
|
|
@@ -126,7 +128,7 @@ function useFetchProductListingPageData({ languageCode, pageUrl, }) {
|
|
|
126
128
|
return useQuery({
|
|
127
129
|
gcTime: 1000 * 60 * 60 * 24,
|
|
128
130
|
queryFn: async () => {
|
|
129
|
-
const res = await fetch(`${config.
|
|
131
|
+
const res = await fetch(`${config.PROXY_API_URL}/api/v1/plp/?pageUrl=${pageUrl}`, {
|
|
130
132
|
headers: { 'Current-Language-Id': languageCode },
|
|
131
133
|
});
|
|
132
134
|
if (!res.ok)
|
|
@@ -6893,7 +6895,7 @@ const createSonicSearchClient = ({ apiKey, appId, host, path, }) => {
|
|
|
6893
6895
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6894
6896
|
// @ts-ignore
|
|
6895
6897
|
searchClient.search = async (requests) => {
|
|
6896
|
-
const res = await fetch(`${config.
|
|
6898
|
+
const res = await fetch(`${config.PROXY_API_URL}${path}`, {
|
|
6897
6899
|
body: JSON.stringify({ requests }),
|
|
6898
6900
|
headers: { 'Content-Type': 'application/json' },
|
|
6899
6901
|
method: 'post',
|
|
@@ -7496,7 +7498,7 @@ const recentSearchesPlugin = createLocalStorageRecentSearchesPlugin({
|
|
|
7496
7498
|
});
|
|
7497
7499
|
|
|
7498
7500
|
const GlobalSearchContext = createContext(null);
|
|
7499
|
-
function AlgoliaSearchProvider({ children, searchClient, }) {
|
|
7501
|
+
function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
7500
7502
|
const [state, setState] = useState({
|
|
7501
7503
|
activeItemId: null,
|
|
7502
7504
|
collections: [],
|
|
@@ -7506,6 +7508,13 @@ function AlgoliaSearchProvider({ children, searchClient, }) {
|
|
|
7506
7508
|
query: '',
|
|
7507
7509
|
status: 'idle',
|
|
7508
7510
|
});
|
|
7511
|
+
const searchClient = useMemo(() => _searchClient ||
|
|
7512
|
+
createSonicSearchClient({
|
|
7513
|
+
apiKey: config.ALGOLIA_API_KEY,
|
|
7514
|
+
appId: config.ALGOLIA_APP_ID,
|
|
7515
|
+
host: config.ALGOLIA_PROXY_HOST,
|
|
7516
|
+
path: '/autocomplete',
|
|
7517
|
+
}), [_searchClient]);
|
|
7509
7518
|
const languageCode = useLanguageCode();
|
|
7510
7519
|
const index = getAlgoliaIndex(environment, languageCode);
|
|
7511
7520
|
const productsIndexName = index.default;
|