@riosst100/pwa-marketplace 1.2.6 → 1.2.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.
Files changed (129) hide show
  1. package/.github/workflows/dependabot.yml +28 -28
  2. package/package.json +18 -18
  3. package/src/Utilities/graphQL.js +76 -76
  4. package/src/componentOverrideMapping.js +17 -16
  5. package/src/components/BecomeSeller/becomeSeller.js +335 -335
  6. package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
  7. package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
  8. package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
  9. package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
  10. package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
  11. package/src/components/Filter/index.js +53 -53
  12. package/src/components/Header/becomeSellerLink.js +28 -28
  13. package/src/components/Header/becomeSellerLink.module.css +12 -12
  14. package/src/components/Header/websiteSwitcher.js +109 -109
  15. package/src/components/Pagination/index.js +49 -40
  16. package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
  17. package/src/components/ProductItem/index.js +50 -50
  18. package/src/components/Search/index.js +16 -16
  19. package/src/components/Seller/index.js +1 -1
  20. package/src/components/Seller/seller.js +249 -42
  21. package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
  22. package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
  23. package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
  24. package/src/components/SellerInformation/index.js +1 -1
  25. package/src/components/SellerInformation/sellerInformation.js +90 -84
  26. package/src/components/SellerLocation/index.js +1 -1
  27. package/src/components/SellerLocation/sellerLocation.js +19 -18
  28. package/src/components/SellerLocation/sellerLocationItem.js +27 -25
  29. package/src/components/SellerPage/sellerPage.js +9 -9
  30. package/src/components/SellerProducts/sellerProducts.js +47 -218
  31. package/src/components/SellerReview/index.js +1 -1
  32. package/src/components/SellerReview/sellerReview.js +143 -143
  33. package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
  34. package/src/components/SellerVerification/sellerVerification.js +198 -198
  35. package/src/components/SellerVerification/sellerVerification.module.css +47 -47
  36. package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
  37. package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
  38. package/src/components/SortBy/index.js +24 -16
  39. package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
  40. package/src/components/commons/Slider/index.js +13 -13
  41. package/src/components/commons/Tabs/index.js +64 -62
  42. package/src/index.js +6 -6
  43. package/src/intercept.js +113 -113
  44. package/src/moduleOverrideWebpackPlugin.js +70 -70
  45. package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
  46. package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
  47. package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
  48. package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
  49. package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
  50. package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
  51. package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
  52. package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
  53. package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
  54. package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
  55. package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
  56. package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -118
  57. package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
  58. package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
  59. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
  60. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
  61. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
  62. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
  63. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
  64. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
  65. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
  66. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
  67. package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
  68. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
  69. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
  70. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
  71. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
  72. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
  73. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
  74. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
  75. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
  76. package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
  77. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
  78. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
  79. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
  80. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
  81. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
  82. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
  83. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
  84. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
  85. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
  86. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
  87. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
  88. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
  89. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
  90. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
  91. package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
  92. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
  93. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
  94. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
  95. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
  96. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
  97. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
  98. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
  99. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
  100. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
  101. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
  102. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
  103. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
  104. package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
  105. package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
  106. package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
  107. package/src/queries/index.js +30 -30
  108. package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
  109. package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
  110. package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
  111. package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
  112. package/src/talons/Header/useBecomeSellerLink.js +13 -13
  113. package/src/talons/Header/useWebsiteSwitcher.js +218 -218
  114. package/src/talons/Seller/seller.gql.js +139 -204
  115. package/src/talons/Seller/useSeller.js +66 -71
  116. package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
  117. package/src/talons/SellerCountry/useSellerCountry.js +25 -25
  118. package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
  119. package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
  120. package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
  121. package/src/theme/vars.js +6 -6
  122. package/src/util/mapSeller.js +7 -7
  123. package/src/components/OperatingHours/index.js +0 -1
  124. package/src/components/OperatingHours/operatingHours.js +0 -32
  125. package/src/components/Seller/sellerAddressCard.js +0 -48
  126. package/src/components/SellerDetail/index.js +0 -1
  127. package/src/components/SellerDetail/sellerDetail.js +0 -158
  128. package/src/components/SellerPage/core.js +0 -10
  129. package/src/talons/SellerProducts/useSellerProducts.js +0 -129
@@ -1,208 +1,208 @@
1
- import { ApolloLink } from '@apollo/client';
2
- import { InMemoryCache } from '@apollo/client/cache';
3
- import { ApolloClient } from '@apollo/client/core';
4
- import { CachePersistor } from 'apollo-cache-persist';
5
- import { useCallback, useEffect, useMemo, useState } from 'react';
6
-
7
- import attachClient from '@magento/peregrine/lib/Apollo/attachClientToStore';
8
- import { clearCartDataFromCache } from '@magento/peregrine/lib/Apollo/clearCartDataFromCache';
9
- import { clearCustomerDataFromCache } from '@magento/peregrine/lib/Apollo/clearCustomerDataFromCache';
10
- import { CACHE_PERSIST_PREFIX } from '@magento/peregrine/lib/Apollo/constants';
11
- import getLinks from '@magento/peregrine/lib/Apollo/links';
12
- import typePolicies from '@magento/peregrine/lib/Apollo/policies';
13
- import { BrowserPersistence } from '@magento/peregrine/lib/util';
14
-
15
- const isServer = !globalThis.document;
16
- const storage = new BrowserPersistence();
17
-
18
- export const useAdapter = props => {
19
- const { apiUrl, configureLinks, origin, store, styles } = props;
20
-
21
- // Custom
22
- const websiteCodes = [];
23
-
24
- AVAILABLE_WEBSITES.forEach(store => {
25
- websiteCodes.push(store.website_code);
26
- });
27
-
28
- websiteCodes.sort((a, b) => b.length - a.length);
29
-
30
- const { location } = globalThis;
31
- const match = location && location.pathname.split("/")[1];
32
- let websiteCodeInUrl = websiteCodes.find((str) => str === match);
33
-
34
- let isBaseWebsite = false;
35
-
36
- let websiteCode = storage.getItem('website_code');
37
-
38
- if (!websiteCodeInUrl) {
39
- isBaseWebsite = true;
40
- }
41
-
42
- let basename = '/';
43
-
44
- const urlHasStoreCode = isBaseWebsite ? false : true;
45
- if (urlHasStoreCode) {
46
- basename = `/${websiteCode}`;
47
- }
48
-
49
- const [initialized, setInitialized] = useState(false);
50
-
51
- const apiBase = useMemo(
52
- () => apiUrl || new URL('/graphql', origin).toString(),
53
- [apiUrl, origin]
54
- );
55
-
56
- const apolloLink = useMemo(() => {
57
- let links = getLinks(apiBase);
58
-
59
- if (configureLinks) {
60
- links = configureLinks(links, apiBase);
61
- }
62
-
63
- return ApolloLink.from(Array.from(links.values()));
64
- }, [apiBase, configureLinks]);
65
-
66
- const createApolloClient = useCallback((cache, link) => {
67
- return new ApolloClient({
68
- cache,
69
- link,
70
- ssrMode: isServer
71
- });
72
- }, []);
73
-
74
- const createCachePersistor = useCallback((storeCode, cache) => {
75
- return isServer
76
- ? null
77
- : new CachePersistor({
78
- key: `${CACHE_PERSIST_PREFIX}-${storeCode}`,
79
- cache,
80
- storage: globalThis.localStorage,
81
- debug: process.env.NODE_ENV === 'development'
82
- });
83
- }, []);
84
-
85
- const clearCacheData = useCallback(
86
- async (client, cacheType) => {
87
- const storeCode = storage.getItem('store_view_code') || 'default';
88
-
89
- // Clear current store
90
- if (cacheType === 'cart') {
91
- await clearCartDataFromCache(client);
92
- } else if (cacheType === 'customer') {
93
- await clearCustomerDataFromCache(client);
94
- }
95
-
96
- // Clear other stores
97
- for (const store of AVAILABLE_STORE_VIEWS) {
98
- if (store.store_code !== storeCode) {
99
- // Get saved data directly from local storage
100
- const existingStorePersistor = globalThis.localStorage.getItem(
101
- `${CACHE_PERSIST_PREFIX}-${store.store_code}`
102
- );
103
-
104
- // Make sure we have data available
105
- if (
106
- existingStorePersistor &&
107
- Object.keys(existingStorePersistor).length > 0
108
- ) {
109
- const storeCache = new InMemoryCache();
110
-
111
- // Restore available data
112
- storeCache.restore(JSON.parse(existingStorePersistor));
113
-
114
- const storeClient = createApolloClient(
115
- storeCache,
116
- apolloLink
117
- );
118
-
119
- storeClient.persistor = isServer
120
- ? null
121
- : createCachePersistor(
122
- store.store_code,
123
- storeCache
124
- );
125
-
126
- // Clear other store
127
- if (cacheType === 'cart') {
128
- await clearCartDataFromCache(storeClient);
129
- } else if (cacheType === 'customer') {
130
- await clearCustomerDataFromCache(storeClient);
131
- }
132
- }
133
- }
134
- }
135
- },
136
- [apolloLink, createApolloClient, createCachePersistor]
137
- );
138
-
139
- const apolloClient = useMemo(() => {
140
- const storeCode = storage.getItem('store_view_code') || 'default';
141
- const client = createApolloClient(preInstantiatedCache, apolloLink);
142
- const persistor = isServer
143
- ? null
144
- : createCachePersistor(storeCode, preInstantiatedCache);
145
-
146
- client.apiBase = apiBase;
147
- client.persistor = persistor;
148
- client.clearCacheData = clearCacheData;
149
-
150
- return client;
151
- }, [
152
- apiBase,
153
- apolloLink,
154
- clearCacheData,
155
- createApolloClient,
156
- createCachePersistor
157
- ]);
158
-
159
- const getUserConfirmation = useCallback(async (message, callback) => {
160
- if (typeof globalThis.handleRouteChangeConfirmation === 'function') {
161
- return globalThis.handleRouteChangeConfirmation(message, callback);
162
- }
163
-
164
- return callback(globalThis.confirm(message));
165
- }, []);
166
-
167
- const apolloProps = { client: apolloClient };
168
- const reduxProps = { store };
169
- const routerProps = { basename, getUserConfirmation };
170
- const styleProps = { initialState: styles };
171
-
172
- // perform blocking async work here
173
- useEffect(() => {
174
- if (initialized) return;
175
-
176
- // immediately invoke this async function
177
- (async () => {
178
- // restore persisted data to the Apollo cache
179
- await apolloClient.persistor.restore();
180
-
181
- // attach the Apollo client to the Redux store
182
- await attachClient(apolloClient);
183
-
184
- // mark this routine as complete
185
- setInitialized(true);
186
- })();
187
- }, [apolloClient, initialized]);
188
-
189
- return {
190
- apolloProps,
191
- initialized,
192
- reduxProps,
193
- routerProps,
194
- styleProps,
195
- urlHasStoreCode
196
- };
197
- };
198
-
199
- /**
200
- * To improve initial load time, create an apollo cache object as soon as
201
- * this module is executed, since it doesn't depend on any component props.
202
- * The tradeoff is that we may be creating an instance we don't end up needing.
203
- */
204
- const preInstantiatedCache = new InMemoryCache({
205
- // POSSIBLE_TYPES is injected into the bundle by webpack at build time.
206
- possibleTypes: POSSIBLE_TYPES,
207
- typePolicies
208
- });
1
+ import { ApolloLink } from '@apollo/client';
2
+ import { InMemoryCache } from '@apollo/client/cache';
3
+ import { ApolloClient } from '@apollo/client/core';
4
+ import { CachePersistor } from 'apollo-cache-persist';
5
+ import { useCallback, useEffect, useMemo, useState } from 'react';
6
+
7
+ import attachClient from '@magento/peregrine/lib/Apollo/attachClientToStore';
8
+ import { clearCartDataFromCache } from '@magento/peregrine/lib/Apollo/clearCartDataFromCache';
9
+ import { clearCustomerDataFromCache } from '@magento/peregrine/lib/Apollo/clearCustomerDataFromCache';
10
+ import { CACHE_PERSIST_PREFIX } from '@magento/peregrine/lib/Apollo/constants';
11
+ import getLinks from '@magento/peregrine/lib/Apollo/links';
12
+ import typePolicies from '@magento/peregrine/lib/Apollo/policies';
13
+ import { BrowserPersistence } from '@magento/peregrine/lib/util';
14
+
15
+ const isServer = !globalThis.document;
16
+ const storage = new BrowserPersistence();
17
+
18
+ export const useAdapter = props => {
19
+ const { apiUrl, configureLinks, origin, store, styles } = props;
20
+
21
+ // Custom
22
+ const websiteCodes = [];
23
+
24
+ AVAILABLE_WEBSITES.forEach(store => {
25
+ websiteCodes.push(store.website_code);
26
+ });
27
+
28
+ websiteCodes.sort((a, b) => b.length - a.length);
29
+
30
+ const { location } = globalThis;
31
+ const match = location && location.pathname.split("/")[1];
32
+ let websiteCodeInUrl = websiteCodes.find((str) => str === match);
33
+
34
+ let isBaseWebsite = false;
35
+
36
+ let websiteCode = storage.getItem('website_code');
37
+
38
+ if (!websiteCodeInUrl) {
39
+ isBaseWebsite = true;
40
+ }
41
+
42
+ let basename = '/';
43
+
44
+ const urlHasStoreCode = isBaseWebsite ? false : true;
45
+ if (urlHasStoreCode) {
46
+ basename = `/${websiteCode}`;
47
+ }
48
+
49
+ const [initialized, setInitialized] = useState(false);
50
+
51
+ const apiBase = useMemo(
52
+ () => apiUrl || new URL('/graphql', origin).toString(),
53
+ [apiUrl, origin]
54
+ );
55
+
56
+ const apolloLink = useMemo(() => {
57
+ let links = getLinks(apiBase);
58
+
59
+ if (configureLinks) {
60
+ links = configureLinks(links, apiBase);
61
+ }
62
+
63
+ return ApolloLink.from(Array.from(links.values()));
64
+ }, [apiBase, configureLinks]);
65
+
66
+ const createApolloClient = useCallback((cache, link) => {
67
+ return new ApolloClient({
68
+ cache,
69
+ link,
70
+ ssrMode: isServer
71
+ });
72
+ }, []);
73
+
74
+ const createCachePersistor = useCallback((storeCode, cache) => {
75
+ return isServer
76
+ ? null
77
+ : new CachePersistor({
78
+ key: `${CACHE_PERSIST_PREFIX}-${storeCode}`,
79
+ cache,
80
+ storage: globalThis.localStorage,
81
+ debug: process.env.NODE_ENV === 'development'
82
+ });
83
+ }, []);
84
+
85
+ const clearCacheData = useCallback(
86
+ async (client, cacheType) => {
87
+ const storeCode = storage.getItem('store_view_code') || 'default';
88
+
89
+ // Clear current store
90
+ if (cacheType === 'cart') {
91
+ await clearCartDataFromCache(client);
92
+ } else if (cacheType === 'customer') {
93
+ await clearCustomerDataFromCache(client);
94
+ }
95
+
96
+ // Clear other stores
97
+ for (const store of AVAILABLE_STORE_VIEWS) {
98
+ if (store.store_code !== storeCode) {
99
+ // Get saved data directly from local storage
100
+ const existingStorePersistor = globalThis.localStorage.getItem(
101
+ `${CACHE_PERSIST_PREFIX}-${store.store_code}`
102
+ );
103
+
104
+ // Make sure we have data available
105
+ if (
106
+ existingStorePersistor &&
107
+ Object.keys(existingStorePersistor).length > 0
108
+ ) {
109
+ const storeCache = new InMemoryCache();
110
+
111
+ // Restore available data
112
+ storeCache.restore(JSON.parse(existingStorePersistor));
113
+
114
+ const storeClient = createApolloClient(
115
+ storeCache,
116
+ apolloLink
117
+ );
118
+
119
+ storeClient.persistor = isServer
120
+ ? null
121
+ : createCachePersistor(
122
+ store.store_code,
123
+ storeCache
124
+ );
125
+
126
+ // Clear other store
127
+ if (cacheType === 'cart') {
128
+ await clearCartDataFromCache(storeClient);
129
+ } else if (cacheType === 'customer') {
130
+ await clearCustomerDataFromCache(storeClient);
131
+ }
132
+ }
133
+ }
134
+ }
135
+ },
136
+ [apolloLink, createApolloClient, createCachePersistor]
137
+ );
138
+
139
+ const apolloClient = useMemo(() => {
140
+ const storeCode = storage.getItem('store_view_code') || 'default';
141
+ const client = createApolloClient(preInstantiatedCache, apolloLink);
142
+ const persistor = isServer
143
+ ? null
144
+ : createCachePersistor(storeCode, preInstantiatedCache);
145
+
146
+ client.apiBase = apiBase;
147
+ client.persistor = persistor;
148
+ client.clearCacheData = clearCacheData;
149
+
150
+ return client;
151
+ }, [
152
+ apiBase,
153
+ apolloLink,
154
+ clearCacheData,
155
+ createApolloClient,
156
+ createCachePersistor
157
+ ]);
158
+
159
+ const getUserConfirmation = useCallback(async (message, callback) => {
160
+ if (typeof globalThis.handleRouteChangeConfirmation === 'function') {
161
+ return globalThis.handleRouteChangeConfirmation(message, callback);
162
+ }
163
+
164
+ return callback(globalThis.confirm(message));
165
+ }, []);
166
+
167
+ const apolloProps = { client: apolloClient };
168
+ const reduxProps = { store };
169
+ const routerProps = { basename, getUserConfirmation };
170
+ const styleProps = { initialState: styles };
171
+
172
+ // perform blocking async work here
173
+ useEffect(() => {
174
+ if (initialized) return;
175
+
176
+ // immediately invoke this async function
177
+ (async () => {
178
+ // restore persisted data to the Apollo cache
179
+ await apolloClient.persistor.restore();
180
+
181
+ // attach the Apollo client to the Redux store
182
+ await attachClient(apolloClient);
183
+
184
+ // mark this routine as complete
185
+ setInitialized(true);
186
+ })();
187
+ }, [apolloClient, initialized]);
188
+
189
+ return {
190
+ apolloProps,
191
+ initialized,
192
+ reduxProps,
193
+ routerProps,
194
+ styleProps,
195
+ urlHasStoreCode
196
+ };
197
+ };
198
+
199
+ /**
200
+ * To improve initial load time, create an apollo cache object as soon as
201
+ * this module is executed, since it doesn't depend on any component props.
202
+ * The tradeoff is that we may be creating an instance we don't end up needing.
203
+ */
204
+ const preInstantiatedCache = new InMemoryCache({
205
+ // POSSIBLE_TYPES is injected into the bundle by webpack at build time.
206
+ possibleTypes: POSSIBLE_TYPES,
207
+ typePolicies
208
+ });
@@ -1,45 +1,45 @@
1
- import { gql } from '@apollo/client';
2
-
3
- export const GET_STORE_CONFIG_DATA = gql`
4
- query getStoreConfigData {
5
- # eslint-disable-next-line @graphql-eslint/require-id-when-available
6
- storeConfig {
7
- store_code
8
- store_name
9
- store_group_name
10
- website_code
11
- }
12
- }
13
- `;
14
-
15
- export const GET_ROUTE_DATA = gql`
16
- query getRouteData($url: String!) {
17
- route(url: $url) {
18
- relative_url
19
- }
20
- }
21
- `;
22
-
23
- export const GET_AVAILABLE_STORES_DATA = gql`
24
- query getAvailableStoresData {
25
- # eslint-disable-next-line @graphql-eslint/require-id-when-available
26
- availableStores {
27
- default_display_currency_code
28
- locale
29
- secure_base_media_url
30
- store_code
31
- store_group_code
32
- store_group_name
33
- store_name
34
- store_sort_order
35
- website_code
36
- is_default_store
37
- }
38
- }
39
- `;
40
-
41
- export default {
42
- getStoreConfigData: GET_STORE_CONFIG_DATA,
43
- getRouteData: GET_ROUTE_DATA,
44
- getAvailableStoresData: GET_AVAILABLE_STORES_DATA
45
- };
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const GET_STORE_CONFIG_DATA = gql`
4
+ query getStoreConfigData {
5
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
6
+ storeConfig {
7
+ store_code
8
+ store_name
9
+ store_group_name
10
+ website_code
11
+ }
12
+ }
13
+ `;
14
+
15
+ export const GET_ROUTE_DATA = gql`
16
+ query getRouteData($url: String!) {
17
+ route(url: $url) {
18
+ relative_url
19
+ }
20
+ }
21
+ `;
22
+
23
+ export const GET_AVAILABLE_STORES_DATA = gql`
24
+ query getAvailableStoresData {
25
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
26
+ availableStores {
27
+ default_display_currency_code
28
+ locale
29
+ secure_base_media_url
30
+ store_code
31
+ store_group_code
32
+ store_group_name
33
+ store_name
34
+ store_sort_order
35
+ website_code
36
+ is_default_store
37
+ }
38
+ }
39
+ `;
40
+
41
+ export default {
42
+ getStoreConfigData: GET_STORE_CONFIG_DATA,
43
+ getRouteData: GET_ROUTE_DATA,
44
+ getAvailableStoresData: GET_AVAILABLE_STORES_DATA
45
+ };