@riosst100/pwa-marketplace 3.1.5 → 3.1.6

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.6",
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',
@@ -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;
@@ -8,6 +8,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
10
 
11
+
11
12
  const storage = new BrowserPersistence();
12
13
 
13
14
  const Adapter = props => {
@@ -22,6 +23,9 @@ const Adapter = props => {
22
23
  routerProps
23
24
  } = talonProps;
24
25
 
26
+
27
+
28
+
25
29
  const websiteCodes = [];
26
30
  const websiteStores = useMemo(() => ({}), []);
27
31
  const storeCurrencies = useMemo(() => ({}), []);
@@ -58,7 +62,48 @@ const Adapter = props => {
58
62
  }
59
63
  }, [websiteCodeInUrl])
60
64
 
65
+ const currentWebsiteCode = storage && storage.getItem('website_code') || process.env.WEBSITE_CODE;
66
+
61
67
  useEffect(() => {
68
+ if (!websiteCodeInUrl) {
69
+ // history.replace(location.pathname + location.search)
70
+ } else if (websiteCodeInUrl && websiteCodeInUrl !== currentWebsiteCode) {
71
+ const storeCodeInUrl = websiteStores[websiteCodeInUrl];
72
+
73
+ // await removeCart();
74
+
75
+ // alert(storeCodeInUrl)
76
+
77
+ // update store/website saat url berubah, misal /id ke /sg
78
+
79
+ // issue store view code gk berubah, klo di graphql aman
80
+
81
+ // ini update di graphql dan di cookie, tapi di cookie beda klo ga di hardcode
82
+
83
+ // ini oke, store di graphql dari sini
84
+ // storeCodeInUrl = 'id_id_store_view';
85
+ // console.log('storeCodeInUrl',storeCodeInUrl)
86
+
87
+ // await apolloClient.clearCacheData(apolloClient, 'cart');
88
+ // await removeCart();
89
+ storage.removeItem('cartId');
90
+
91
+ storage.setItem('store_view_code', storeCodeInUrl);
92
+ storage.setItem('website_code', websiteCodeInUrl);
93
+ storage.setItem(
94
+ 'store_view_currency',
95
+ storeCurrencies[storeCodeInUrl]
96
+ );
97
+ storage.setItem(
98
+ 'store_view_secure_base_media_url',
99
+ storeSecureBaseMediaUrl[storeCodeInUrl]
100
+ );
101
+
102
+ // We're required to reload the page as the basename doesn't
103
+ // change entirely without a full page reload.
104
+ // history.go(0);
105
+ }
106
+
62
107
  if (!websiteCodeInUrl && getWebsiteByUserIp) {
63
108
  setVerifyUserIp(false);
64
109
 
@@ -82,6 +127,8 @@ const Adapter = props => {
82
127
 
83
128
  let storeCodeInUrl = websiteStores[websiteCode];
84
129
 
130
+ storage.removeItem('cartId');
131
+
85
132
  storage.setItem('store_view_code', storeCodeInUrl);
86
133
  storage.setItem('website_code', websiteCode);
87
134
  storage.setItem(
@@ -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,8 +198,8 @@ 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();
201
+ // await apolloClient.clearCacheData(apolloClient, 'cart');
202
+ // await removeCart();
203
203
 
204
204
  if (newWebsiteCode) {
205
205
  globalThis.location.assign(`/${newWebsiteCode}${newPath || ''}`);