@riosst100/pwa-marketplace 3.1.5 → 3.1.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "3.1.5",
4
+ "version": "3.1.7",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -15,6 +15,7 @@ module.exports = componentOverrideMapping = {
15
15
  [`@magento/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js',
16
16
  [`@magento/peregrine/lib/talons/Adapter/useAdapter.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js',
17
17
  [`@magento/peregrine/lib/talons/Header/useStoreSwitcher.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js',
18
+ [`@magento/peregrine/lib/talons/Header/useAccountTrigger.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/useAccountTrigger.js',
18
19
  [`@magento/peregrine/lib/talons/Header/storeSwitcher.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js',
19
20
  [`@magento/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js',
20
21
  [`@magento/peregrine/lib/talons/Region/useRegion.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Region/useRegion.js',
@@ -0,0 +1 @@
1
+ export { default } from './maintenancePage';
@@ -0,0 +1,37 @@
1
+ import React, { Fragment } from 'react';
2
+ import { StoreTitle } from '@magento/venia-ui/lib/components/Head';
3
+ import defaultClasses from './maintenancePage.module.css';
4
+ import { useStyle } from '@magento/venia-ui/lib/classify';
5
+
6
+ const MaintenancePage = props => {
7
+
8
+ const classes = useStyle(defaultClasses);
9
+
10
+ return (
11
+ <>
12
+ <head>
13
+ <meta charset="UTF-8" />
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
15
+ <title>We'll Be Back Soon</title>
16
+ </head>
17
+ <body className={classes.body}>
18
+ <div className={classes.container}>
19
+ <img src="https://seller-preprod.tcgcollective.co/media/logo/default/FullLogo_Transparent_NoBuffer_14_.png" alt="Logo" className={classes.logo} />
20
+ <br />
21
+ <h1 className={classes.h1}>We're Temporarily Offline</h1>
22
+ <img src="https://seller-preprod.tcgcollective.co/media/maintenance.webp" alt="Logo" className={classes.logo} />
23
+ <p className={classes.p}>
24
+ Our website is currently undergoing scheduled maintenance. <br/>
25
+ We should be back shortly. Thank you for your patience.
26
+ </p>
27
+ <div className={classes.footer}>
28
+ &copy; <span id="year">{new Date().getFullYear()}</span> TCG Collective. All rights reserved.
29
+ {/* | <a href="mailto:support@yourdomain.com">Contact Support</a> */}
30
+ </div>
31
+ </div>
32
+ </body>
33
+ </>
34
+ );
35
+ }
36
+
37
+ export default MaintenancePage;
@@ -0,0 +1,45 @@
1
+ .body {
2
+ background-color: #f3f4f6;
3
+ color: #333;
4
+ font-family: 'Arial', sans-serif;
5
+ text-align: center;
6
+ /* padding: 50px; */
7
+ display: flex;
8
+ justify-content: center; /* Horizontal center */
9
+ align-items: center; /* Vertical center */
10
+ height: 100vh; /* Full height layar */
11
+ margin: 0;
12
+ }
13
+ .container {
14
+ max-width: 700px;
15
+ margin: auto;
16
+ padding: 30px;
17
+ background: #fff;
18
+ border-radius: 12px;
19
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
20
+ }
21
+ .h1 {
22
+ font-size: 2.5em;
23
+ color: #1a202c;
24
+ padding: 20px;
25
+ }
26
+ .p {
27
+ font-size: 16px;
28
+ line-height: 1.6;
29
+ color: #4a5568;
30
+ padding: 20px;
31
+ }
32
+ .logo {
33
+ width: 200px;
34
+ display: inline-block;
35
+ margin-bottom: 10px;
36
+ }
37
+ .footer {
38
+ margin-top: 20px;
39
+ font-size: 14px;
40
+ color: #718096;
41
+ }
42
+ .footer a {
43
+ color: #3182ce;
44
+ text-decoration: none;
45
+ }
@@ -11,6 +11,7 @@ import { CACHE_PERSIST_PREFIX } from '@magento/peregrine/lib/Apollo/constants';
11
11
  import getLinks from '@magento/peregrine/lib/Apollo/links';
12
12
  import typePolicies from '@magento/peregrine/lib/Apollo/policies';
13
13
  import { BrowserPersistence } from '@magento/peregrine/lib/util';
14
+ import axios from 'axios';
14
15
 
15
16
  const isServer = !globalThis.document;
16
17
  const storage = new BrowserPersistence();
@@ -47,6 +48,7 @@ export const useAdapter = props => {
47
48
  }
48
49
 
49
50
  const [initialized, setInitialized] = useState(false);
51
+ const [isMaintenance, setIsMaintenance] = useState(false);
50
52
 
51
53
  const apiBase = useMemo(
52
54
  () => apiUrl || new URL('/graphql', origin).toString(),
@@ -186,13 +188,33 @@ export const useAdapter = props => {
186
188
  })();
187
189
  }, [apolloClient, initialized]);
188
190
 
191
+ useEffect(() => {
192
+ if (initialized) return;
193
+
194
+ // immediately invoke this async function
195
+ (async () => {
196
+ axios.get(apiBase).then((response) => {
197
+ setIsMaintenance(false)
198
+ }).catch((error) => {
199
+ const status = error.response.status;
200
+ if (status != 200) {
201
+ setIsMaintenance(true)
202
+ } else {
203
+ setIsMaintenance(false)
204
+ }
205
+ });
206
+ })();
207
+ }, [apiBase,initialized]);
208
+
189
209
  return {
190
210
  apolloProps,
211
+ isMaintenance,
191
212
  initialized,
192
213
  reduxProps,
193
214
  routerProps,
194
215
  styleProps,
195
- urlHasStoreCode
216
+ urlHasStoreCode,
217
+ apiBase
196
218
  };
197
219
  };
198
220
 
@@ -134,8 +134,6 @@ export const useCreateAccount = props => {
134
134
 
135
135
  storage.setItem('confirm_email', formValues.customer.email);
136
136
 
137
- console.log(formValues.customer.email)
138
-
139
137
  history.push('/verify-email');
140
138
 
141
139
  // Get reCaptchaV3 Data for signIn mutation
@@ -32,24 +32,11 @@ export const useFilterSidebar = props => {
32
32
  const history = useHistory();
33
33
  const { pathname, search } = useLocation();
34
34
 
35
- const allActiveFilters = getFiltersFromSearch(search);
36
-
37
35
  const { data: introspectionData } = useQuery(getFilterInputsQuery, {
38
36
  fetchPolicy: 'cache-and-network',
39
37
  nextFetchPolicy: 'cache-first'
40
38
  });
41
39
 
42
- // const {
43
- // called: subFilterItemsCalled,
44
- // data: subFilterItems,
45
- // loading: subFilterItemsLoading,
46
- // error: subFilterItemsError
47
- // } = useQuery(getSubFiltersQuery,
48
- // {
49
- // fetchPolicy: 'cache-and-network',
50
- // nextFetchPolicy: 'cache-first'
51
- // });
52
-
53
40
  const subFilterItems = [];
54
41
 
55
42
  const attributeCodes = useMemo(
@@ -90,7 +77,7 @@ export const useFilterSidebar = props => {
90
77
 
91
78
  return nextFilters;
92
79
  }, [DISABLED_FILTERS, attributeCodes, introspectionData]);
93
-
80
+
94
81
  const isBooleanFilter = options => {
95
82
  const optionsString = JSON.stringify(options);
96
83
  return (
@@ -257,30 +244,6 @@ export const useFilterSidebar = props => {
257
244
  }, [closeDrawer]);
258
245
 
259
246
  const handleApply = useCallback((...args) => {
260
- const group = args[0];
261
- const item = args[1];
262
-
263
- // REMOVE ACTIVE FILTER
264
- // if (group.includes('card_release')) {
265
- // const subFilter = group.replace("card_release", "card_set");
266
- // filterApi.removeGroup({ group: subFilter });
267
- // }
268
-
269
- // if (group.includes('sc_release')) {
270
- // const subFilter = group.replace("sc_release", "sc_set_name");
271
- // filterApi.removeGroup({ group: subFilter });
272
- // }
273
-
274
- // if (group.includes('sc_set_name')) {
275
- // const subFilter = group.replace("sc_set_name", "sc_release");
276
- // filterApi.removeGroup({ group: subFilter });
277
- // }
278
-
279
- // if (group.includes('card_set')) {
280
- // const subFilter = group.replace("card_set", "card_release");
281
- // filterApi.removeGroup({ group: subFilter });
282
- // }
283
-
284
247
  setIsApplying(true);
285
248
  handleClose();
286
249
  }, [handleClose]);
@@ -0,0 +1,47 @@
1
+ import { useCallback } from 'react';
2
+
3
+ import { useDropdown } from '@magento/peregrine/lib/hooks/useDropdown';
4
+ import { useUserContext } from '@magento/peregrine/lib/context/user';
5
+
6
+ import { useHistory } from 'react-router-dom';
7
+
8
+ /**
9
+ * The useAccountTrigger talon complements the AccountTrigger component.
10
+ *
11
+ * @returns {Object} talonProps
12
+ * @returns {Boolean} talonProps.accountMenuIsOpen - Whether the menu that this trigger toggles is open or not.
13
+ * @returns {Function} talonProps.setAccountMenuIsOpen - Set the value of accoutMenuIsOpen.
14
+ * @returns {Ref} talonProps.accountMenuRef - A React ref to the menu that this trigger toggles.
15
+ * @returns {Ref} talonProps.accountMenuTriggerRef - A React ref to the trigger element itself.
16
+ * @returns {Function} talonProps.handleTriggerClick - A function for handling when the trigger is clicked.
17
+ */
18
+ export const useAccountTrigger = () => {
19
+ const {
20
+ elementRef: accountMenuRef,
21
+ expanded: accountMenuIsOpen,
22
+ setExpanded: setAccountMenuIsOpen,
23
+ triggerRef: accountMenuTriggerRef
24
+ } = useDropdown();
25
+
26
+ const [{ isSignedIn: isUserSignedIn }] = useUserContext();
27
+
28
+ const history = useHistory();
29
+
30
+ const handleTriggerClick = useCallback(() => {
31
+ if (isUserSignedIn) {
32
+ // Toggle the Account Menu.
33
+ setAccountMenuIsOpen(isOpen => !isOpen);
34
+ } else {
35
+ history.push('/sign-in')
36
+ }
37
+ }, [setAccountMenuIsOpen,isUserSignedIn,history]);
38
+
39
+ return {
40
+ accountMenuIsOpen,
41
+ accountMenuRef,
42
+ accountMenuTriggerRef,
43
+ setAccountMenuIsOpen,
44
+ handleTriggerClick,
45
+ isUserSignedIn
46
+ };
47
+ };
@@ -128,7 +128,7 @@ const CategoryContent = props => {
128
128
  ) : null;
129
129
 
130
130
  const sidebar = shouldShowFilterButtons ? (
131
- <FilterSidebar children={children} filters={filters} prefixes={category ? category.prefixes : []} />
131
+ <FilterSidebar category={category} children={children} filters={filters} prefixes={category ? category.prefixes : []} />
132
132
  ) : shouldShowFilterShimmer ? (
133
133
  <FilterSidebarShimmer />
134
134
  ) : null;
@@ -7,6 +7,8 @@ import App, { AppContextProvider } from '@magento/venia-ui/lib/components/App';
7
7
  import StoreCodeRoute from '@magento/venia-ui/lib/components/StoreCodeRoute';
8
8
  import { useWebsiteByIp } from '@riosst100/pwa-marketplace/src/talons/WebsiteByIp/useWebsiteByIp';
9
9
  import { BrowserPersistence } from '@magento/peregrine/lib/util';
10
+ import MaintenancePage from '@riosst100/pwa-marketplace/src/components/MaintenancePage';
11
+ import axios from 'axios';
10
12
 
11
13
  const storage = new BrowserPersistence();
12
14
 
@@ -19,9 +21,34 @@ const Adapter = props => {
19
21
  apolloProps,
20
22
  initialized,
21
23
  reduxProps,
22
- routerProps
24
+ routerProps,
25
+ isMaintenance,
26
+ apiBase
23
27
  } = talonProps;
24
28
 
29
+ // console.log('isMaintenance',isMaintenance)
30
+
31
+ // useEffect(() => {
32
+ // const fetchData = async () => {
33
+ // axios.get(apiBase).then((response) => {
34
+ // // setIsMaintenance(false)
35
+ // }).catch((error) => {
36
+ // const status = error.response.status;
37
+ // if (status != 200) {
38
+ // console.log('status',status)
39
+ // return <MaintenancePage />;
40
+ // // setIsMaintenance(true)
41
+ // }
42
+ // });
43
+ // };
44
+
45
+ // fetchData();
46
+
47
+
48
+ // if (isMaintenance) {
49
+ // return <MaintenancePage />;
50
+ // }
51
+
25
52
  const websiteCodes = [];
26
53
  const websiteStores = useMemo(() => ({}), []);
27
54
  const storeCurrencies = useMemo(() => ({}), []);
@@ -58,7 +85,48 @@ const Adapter = props => {
58
85
  }
59
86
  }, [websiteCodeInUrl])
60
87
 
88
+ const currentWebsiteCode = storage && storage.getItem('website_code') || process.env.WEBSITE_CODE;
89
+
61
90
  useEffect(() => {
91
+ if (!websiteCodeInUrl) {
92
+ // history.replace(location.pathname + location.search)
93
+ } else if (websiteCodeInUrl && websiteCodeInUrl !== currentWebsiteCode) {
94
+ const storeCodeInUrl = websiteStores[websiteCodeInUrl];
95
+
96
+ // await removeCart();
97
+
98
+ // alert(storeCodeInUrl)
99
+
100
+ // update store/website saat url berubah, misal /id ke /sg
101
+
102
+ // issue store view code gk berubah, klo di graphql aman
103
+
104
+ // ini update di graphql dan di cookie, tapi di cookie beda klo ga di hardcode
105
+
106
+ // ini oke, store di graphql dari sini
107
+ // storeCodeInUrl = 'id_id_store_view';
108
+ // console.log('storeCodeInUrl',storeCodeInUrl)
109
+
110
+ // await apolloClient.clearCacheData(apolloClient, 'cart');
111
+ // await removeCart();
112
+ storage.removeItem('cartId');
113
+
114
+ storage.setItem('store_view_code', storeCodeInUrl);
115
+ storage.setItem('website_code', websiteCodeInUrl);
116
+ storage.setItem(
117
+ 'store_view_currency',
118
+ storeCurrencies[storeCodeInUrl]
119
+ );
120
+ storage.setItem(
121
+ 'store_view_secure_base_media_url',
122
+ storeSecureBaseMediaUrl[storeCodeInUrl]
123
+ );
124
+
125
+ // We're required to reload the page as the basename doesn't
126
+ // change entirely without a full page reload.
127
+ // history.go(0);
128
+ }
129
+
62
130
  if (!websiteCodeInUrl && getWebsiteByUserIp) {
63
131
  setVerifyUserIp(false);
64
132
 
@@ -82,6 +150,8 @@ const Adapter = props => {
82
150
 
83
151
  let storeCodeInUrl = websiteStores[websiteCode];
84
152
 
153
+ storage.removeItem('cartId');
154
+
85
155
  storage.setItem('store_view_code', storeCodeInUrl);
86
156
  storage.setItem('website_code', websiteCode);
87
157
  storage.setItem(
@@ -101,6 +171,10 @@ const Adapter = props => {
101
171
  return null;
102
172
  }
103
173
 
174
+ if (isMaintenance) {
175
+ return <MaintenancePage />;
176
+ }
177
+
104
178
  const children = props.children || <App />;
105
179
 
106
180
  return !verifyUserIp && (
@@ -31,7 +31,7 @@ const CreateAccountPage = props => {
31
31
  };
32
32
 
33
33
  CreateAccountPage.defaultProps = {
34
- signedInRedirectUrl: '/order-history',
34
+ signedInRedirectUrl: '/',
35
35
  signInPageUrl: '/sign-in'
36
36
  };
37
37
 
@@ -7,11 +7,13 @@ import CurrentFilter from './currentFilter';
7
7
  import defaultClasses from './currentFilters.module.css';
8
8
 
9
9
  const CurrentFilters = props => {
10
- const { filterApi, filterState, onRemove, filterNames } = props;
10
+ const { category, filterApi, filterState, onRemove, filterNames } = props;
11
11
  const { removeItem } = filterApi;
12
12
  const classes = useStyle(defaultClasses, props.classes);
13
13
  const { formatMessage } = useIntl();
14
14
 
15
+ const defaultTopFilterAttrCode = category.default_top_filter.attribute_code;
16
+
15
17
  // create elements and params at the same time for efficiency
16
18
  const filterElements = useMemo(() => {
17
19
  const elements = [];
@@ -20,9 +22,7 @@ const CurrentFilters = props => {
20
22
  const { title, value } = item || {};
21
23
  const key = `${group}::${title}_${value}`;
22
24
 
23
- const customAttributeLandingPage = ['bricks_categories','sc_sports_categories','card_game', 'sc_baseball_release','auction','special_price','lof_preorder','card_pre_orders','sc_baseball_inserts','sc_baseball_parallel','sc_set_type'];
24
-
25
- if (!customAttributeLandingPage.includes(group)) {
25
+ if (group != defaultTopFilterAttrCode) {
26
26
  elements.push(
27
27
  <li key={key} className={classes.item}>
28
28
  <CurrentFilter
@@ -21,7 +21,7 @@ const SCROLL_OFFSET = 150;
21
21
  * @param {Object} props.filters - filters to display
22
22
  */
23
23
  const FilterSidebar = props => {
24
- const { filters, filterCountToOpen, prefixes } = props;
24
+ const { filters, category, filterCountToOpen, prefixes } = props;
25
25
  const talonProps = useFilterSidebar({ filters });
26
26
  const {
27
27
  filterApi,
@@ -61,17 +61,6 @@ const FilterSidebar = props => {
61
61
 
62
62
  const handleCategoryApplyFilter = useCallback(
63
63
  (...args) => {
64
- // const filterElement = filterRef.current;
65
- // if (
66
- // filterElement &&
67
- // typeof filterElement.getBoundingClientRect === 'function'
68
- // ) {
69
- // const filterTop = filterElement.getBoundingClientRect().top;
70
- // const windowScrollY =
71
- // window.scrollY + filterTop - SCROLL_OFFSET;
72
- // window.scrollTo(0, windowScrollY);
73
- // }
74
-
75
64
  history.push('/' + args[1].path + '.html');
76
65
 
77
66
  if (args[0] != "category_uid") {
@@ -98,6 +87,7 @@ const FilterSidebar = props => {
98
87
  const groupName = filterNames.get(group);
99
88
  const frontendInput = filterFrontendInput.get(group);
100
89
 
90
+
101
91
  let subFilter = null;
102
92
 
103
93
  return (
@@ -167,6 +157,7 @@ const FilterSidebar = props => {
167
157
  </div>
168
158
  <CurrentFilters
169
159
  filterApi={filterApi}
160
+ category={category}
170
161
  filterNames={filterNames}
171
162
  filterState={filterState}
172
163
  onRemove={handleApplyFilter}
@@ -191,7 +182,6 @@ FilterSidebar.propTypes = {
191
182
  root: string,
192
183
  root_open: string
193
184
  }),
194
- prefixes: [],
195
185
  filters: arrayOf(
196
186
  shape({
197
187
  attribute_code: string,
@@ -33,7 +33,7 @@ const SignInPage = props => {
33
33
  SignInPage.defaultProps = {
34
34
  createAccountPageUrl: '/create-account',
35
35
  forgotPasswordPageUrl: '/forgot-password',
36
- signedInRedirectUrl: '/order-history'
36
+ signedInRedirectUrl: '/'
37
37
  };
38
38
 
39
39
  SignInPage.propTypes = {
@@ -1,8 +1,10 @@
1
- import { useEffect, useMemo } from 'react';
2
- import { useHistory } from 'react-router-dom';
3
- import { BrowserPersistence } from '@magento/peregrine/lib/util';
1
+ // import { useEffect, useMemo } from 'react';
2
+ // import { useHistory } from 'react-router-dom';
3
+ // import { BrowserPersistence } from '@magento/peregrine/lib/util';
4
+ // import { useCartContext } from '@magento/peregrine/lib/context/cart';
5
+ // import { useApolloClient, useQuery } from '@apollo/client';
4
6
 
5
- const storage = new BrowserPersistence();
7
+ // const storage = new BrowserPersistence();
6
8
 
7
9
  /**
8
10
  * This component checks for use of a store code in the url that is not the
@@ -10,64 +12,82 @@ const storage = new BrowserPersistence();
10
12
  * and reloads the page so that they are used in the graphQL headers.
11
13
  */
12
14
  const StoreCodeRoute = () => {
13
- const history = useHistory();
15
+ // const history = useHistory();
14
16
 
15
- const websiteCodes = [];
16
- const websiteStores = useMemo(() => ({}), []);
17
- const storeCurrencies = useMemo(() => ({}), []);
18
- const storeSecureBaseMediaUrl = useMemo(() => ({}), []);
17
+ // const websiteCodes = [];
18
+ // const websiteStores = useMemo(() => ({}), []);
19
+ // const storeCurrencies = useMemo(() => ({}), []);
20
+ // const storeSecureBaseMediaUrl = useMemo(() => ({}), []);
19
21
 
20
- AVAILABLE_WEBSITES.forEach(store => {
21
- websiteCodes.push(store.website_code);
22
- websiteStores[store.website_code] = store.store_code;
23
- storeCurrencies[store.store_code] = store.default_display_currency_code;
24
- storeSecureBaseMediaUrl[store.store_code] = store.secure_base_media_url;
25
- });
22
+ // AVAILABLE_WEBSITES.forEach(store => {
23
+ // websiteCodes.push(store.website_code);
24
+ // websiteStores[store.website_code] = store.store_code;
25
+ // storeCurrencies[store.store_code] = store.default_display_currency_code;
26
+ // storeSecureBaseMediaUrl[store.store_code] = store.secure_base_media_url;
27
+ // });
26
28
 
27
- // Sort by length (longest first) to avoid false hits ie "en" matching just
28
- // the "/en" in "/en-us/home.html" when "en-us" is also in storeCodes.
29
- websiteCodes.sort((a, b) => b.length - a.length);
29
+ // // Sort by length (longest first) to avoid false hits ie "en" matching just
30
+ // // the "/en" in "/en-us/home.html" when "en-us" is also in storeCodes.
31
+ // websiteCodes.sort((a, b) => b.length - a.length);
30
32
 
31
- // Find the store code in the url. This will always be the first path.
32
- // ie `https://example.com/fr/foo/baz.html` => `fr`.
33
- const { location } = globalThis;
34
- const match = location && location.pathname.split("/")[1];
35
- let websiteCodeInUrl = websiteCodes.find((str) => str === match);
33
+ // // Find the store code in the url. This will always be the first path.
34
+ // // ie `https://example.com/fr/foo/baz.html` => `fr`.
35
+ // const { location } = globalThis;
36
+ // const match = location && location.pathname.split("/")[1];
37
+ // let websiteCodeInUrl = websiteCodes.find((str) => str === match);
36
38
 
37
- // Determine what the current store code is using the configured basename.
38
- const currentWebsiteCode = storage && storage.getItem('website_code') || process.env.WEBSITE_CODE;
39
+ // // Determine what the current store code is using the configured basename.
40
+ // const currentWebsiteCode = storage && storage.getItem('website_code') || process.env.WEBSITE_CODE;
41
+
42
+
39
43
 
40
44
  // If we find a store code in the url that is not the current one, update
41
45
  // the storage value and refresh so that we start using the new code.
42
- useEffect(() => {
43
- if (!websiteCodeInUrl) {
44
- history.replace(location.pathname + location.search)
45
- } else if (websiteCodeInUrl && websiteCodeInUrl !== currentWebsiteCode) {
46
- let storeCodeInUrl = websiteStores[websiteCodeInUrl];
47
-
48
- storage.setItem('store_view_code', storeCodeInUrl);
49
- storage.setItem('website_code', websiteCodeInUrl);
50
- storage.setItem(
51
- 'store_view_currency',
52
- storeCurrencies[storeCodeInUrl]
53
- );
54
- storage.setItem(
55
- 'store_view_secure_base_media_url',
56
- storeSecureBaseMediaUrl[storeCodeInUrl]
57
- );
46
+ // useEffect(() => {
47
+ // if (!websiteCodeInUrl) {
48
+ // history.replace(location.pathname + location.search)
49
+ // } else if (websiteCodeInUrl && websiteCodeInUrl !== currentWebsiteCode) {
50
+ // const storeCodeInUrl = websiteStores[websiteCodeInUrl];
51
+
52
+ // alert(storeCodeInUrl)
53
+
54
+ // update store/website saat url berubah, misal /id ke /sg
55
+
56
+ // issue store view code gk berubah, klo di graphql aman
57
+
58
+ // ini update di graphql dan di cookie, tapi di cookie beda klo ga di hardcode
59
+
60
+ // ini oke, store di graphql dari sini
61
+ // storeCodeInUrl = 'id_id_store_view';
62
+ // console.log('storeCodeInUrl',storeCodeInUrl)
63
+
64
+ // await apolloClient.clearCacheData(apolloClient, 'cart');
65
+ // await removeCart();
66
+
67
+ // storage.setItem('store_view_code', storeCodeInUrl);
68
+ // storage.setItem('website_code', websiteCodeInUrl);
69
+ // storage.setItem(
70
+ // 'store_view_currency',
71
+ // storeCurrencies[storeCodeInUrl]
72
+ // );
73
+ // storage.setItem(
74
+ // 'store_view_secure_base_media_url',
75
+ // storeSecureBaseMediaUrl[storeCodeInUrl]
76
+ // );
58
77
 
59
78
  // We're required to reload the page as the basename doesn't
60
79
  // change entirely without a full page reload.
61
- history.go(0);
62
- }
63
- }, [
64
- websiteCodeInUrl,
65
- // currentWebsiteCode,
66
- history
67
- // storeCodeInUrl,
68
- // storeCurrencies,
69
- // storeSecureBaseMediaUrl
70
- ]);
80
+ // history.go(0);
81
+ // }
82
+ // }, [
83
+ // websiteCodeInUrl,
84
+ // // currentWebsiteCode,
85
+ // history
86
+ // // , apolloClient, removeCart
87
+ // // storeCodeInUrl,
88
+ // // storeCurrencies,
89
+ // // storeSecureBaseMediaUrl
90
+ // ]);
71
91
 
72
92
  return null;
73
93
  };
@@ -198,9 +198,6 @@ export const useWebsiteSwitcher = (props = {}) => {
198
198
 
199
199
  const newPath = pathName ? `/${pathName}${newSearchParams}` : (accessBaseWebsite ? `/${pathName}${accessBaseWebsite}` : '');
200
200
 
201
- await apolloClient.clearCacheData(apolloClient, 'cart');
202
- await removeCart();
203
-
204
201
  if (newWebsiteCode) {
205
202
  globalThis.location.assign(`/${newWebsiteCode}${newPath || ''}`);
206
203
  } else {