@riosst100/pwa-marketplace 1.3.1 → 1.3.2

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 (28) hide show
  1. package/package.json +1 -1
  2. package/src/componentOverrideMapping.js +5 -0
  3. package/src/components/ShopByCategory/index.js +2 -0
  4. package/src/components/ShopByCategory/shopByCategory.js +69 -0
  5. package/src/components/ShopByCategory/shopByCategory.module.css +58 -0
  6. package/src/components/ShopByCategory/shopByCategory.shimmer.js +24 -0
  7. package/src/components/SubCategory/subCategory.js +31 -0
  8. package/src/overwrites/peregrine/lib/talons/Breadcrumbs/useBreadcrumbs.js +100 -0
  9. package/src/overwrites/peregrine/lib/talons/MegaMenu/megaMenu.gql.js +70 -0
  10. package/src/overwrites/peregrine/lib/talons/MegaMenu/useMegaMenu.js +199 -0
  11. package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +70 -0
  12. package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +141 -0
  13. package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +222 -0
  14. package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +5 -2
  15. package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +157 -0
  16. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +2 -1
  17. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +1 -0
  18. package/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn.js +75 -0
  19. package/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn.module.css +28 -0
  20. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +31 -0
  21. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +1 -0
  22. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +1 -1
  23. package/src/talons/MegaMenu/megaMenu.gql.js +70 -0
  24. package/src/talons/ShopByCategory/index.js +1 -0
  25. package/src/talons/ShopByCategory/shopByCategory.gql.js +38 -0
  26. package/src/talons/ShopByCategory/useShopByCategory.js +69 -0
  27. package/src/talons/SubCategory/subCategory.gql.js +15 -0
  28. package/src/talons/SubCategory/useSubCategory.js +52 -0
@@ -6,6 +6,7 @@ import { useSubMenu } from '@magento/peregrine/lib/talons/MegaMenu/useSubMenu';
6
6
  import { useStyle } from '@magento/venia-ui/lib/classify';
7
7
  import defaultClasses from './submenu.module.css';
8
8
  import SubmenuColumn from './submenuColumn';
9
+ import ShopByColumn from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn';
9
10
 
10
11
  /**
11
12
  * The Submenu component displays submenu in mega menu
@@ -17,6 +18,7 @@ import SubmenuColumn from './submenuColumn';
17
18
  const Submenu = props => {
18
19
  const {
19
20
  items,
21
+ shopByItems,
20
22
  mainNavWidth,
21
23
  isFocused,
22
24
  subMenuState,
@@ -55,6 +57,34 @@ const Submenu = props => {
55
57
  );
56
58
  });
57
59
 
60
+ // const shopByItems = [
61
+ // {
62
+ // name: 'Shop By Franchise',
63
+ // items: [
64
+ // {
65
+ // name: 'Hasbro',
66
+ // url: '/'
67
+ // }
68
+ // ]
69
+ // }
70
+ // ];
71
+
72
+ const shopBy = shopByItems.map((shopBy, index) => {
73
+ const keyboardProps =
74
+ index === shopByItems.length - 1 ? talonProps.keyboardProps : {};
75
+ return (
76
+ <ShopByColumn
77
+ index={index}
78
+ keyboardProps={keyboardProps}
79
+ // key={category.uid}
80
+ shopBy={shopBy}
81
+ // categoryUrlSuffix={categoryUrlSuffix}
82
+ onNavigate={onNavigate}
83
+ handleCloseSubMenu={handleCloseSubMenu}
84
+ />
85
+ );
86
+ });
87
+
58
88
  return (
59
89
  <div className={subMenuClassname}>
60
90
  <div
@@ -62,6 +92,7 @@ const Submenu = props => {
62
92
  style={{ minWidth: mainNavWidth + PADDING_OFFSET }}
63
93
  >
64
94
  {subMenus}
95
+ {shopBy}
65
96
  </div>
66
97
  </div>
67
98
  );
@@ -20,6 +20,7 @@ const SubmenuColumn = props => {
20
20
  onNavigate,
21
21
  handleCloseSubMenu
22
22
  } = props;
23
+
23
24
  const classes = useStyle(defaultClasses, props.classes);
24
25
 
25
26
  const categoryUrl = resourceUrl(
@@ -27,7 +27,7 @@ const SearchField = props => {
27
27
  onFocus={onFocus}
28
28
  onValueChange={onChange}
29
29
  forwardedRef={inputRef}
30
- classes={cn('search input')}
30
+ // classes={cn('search input')}
31
31
  />
32
32
  );
33
33
  };
@@ -0,0 +1,70 @@
1
+ import { gql } from '@apollo/client';
2
+ export const GET_STORE_CONFIG_DATA = gql`
3
+ query GetStoreConfigForMegaMenu {
4
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
5
+ storeConfig {
6
+ store_code
7
+ category_url_suffix
8
+ }
9
+ }
10
+ `;
11
+
12
+ export const GET_MEGA_MENU = gql`
13
+ query getMegaMenu {
14
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
15
+ categoryList {
16
+ uid
17
+ name
18
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
19
+ children {
20
+ uid
21
+ include_in_menu
22
+ name
23
+ position
24
+ url_path
25
+ shop_by {
26
+ name
27
+ items {
28
+ name
29
+ url_path
30
+ }
31
+ }
32
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
33
+ children {
34
+ uid
35
+ include_in_menu
36
+ name
37
+ position
38
+ url_path
39
+ shop_by {
40
+ name
41
+ items {
42
+ name
43
+ url_path
44
+ }
45
+ }
46
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
47
+ children {
48
+ uid
49
+ include_in_menu
50
+ name
51
+ position
52
+ url_path
53
+ shop_by {
54
+ name
55
+ items {
56
+ name
57
+ url_path
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ `;
66
+
67
+ export default {
68
+ getMegaMenuQuery: GET_MEGA_MENU,
69
+ getStoreConfigQuery: GET_STORE_CONFIG_DATA
70
+ };
@@ -0,0 +1 @@
1
+ export { useShopByCategory } from './useShopByCategory';
@@ -0,0 +1,38 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const GET_STORE_CONFIG_DATA = gql`
4
+ query GetStoreConfigForBreadcrumbs {
5
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
6
+ storeConfig {
7
+ store_code
8
+ category_url_suffix
9
+ }
10
+ }
11
+ `;
12
+
13
+ export const GET_CATEGORY_LIST = gql`
14
+ query getCategoryData($id: String!) {
15
+ categories(filters: { category_uid: { eq: $id } }) {
16
+ items {
17
+ uid
18
+ name
19
+ url_path
20
+ parent {
21
+ uid
22
+ name
23
+ url_path
24
+ }
25
+ children {
26
+ uid
27
+ name
28
+ url_path
29
+ }
30
+ }
31
+ }
32
+ }
33
+ `;
34
+
35
+ export default {
36
+ getStoreConfigQuery: GET_STORE_CONFIG_DATA,
37
+ getCategoryQuery: GET_CATEGORY_LIST
38
+ };
@@ -0,0 +1,69 @@
1
+ import { useMemo } from 'react';
2
+ import { useQuery } from '@apollo/client';
3
+
4
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
5
+
6
+ import DEFAULT_OPERATIONS from './shopByCategory.gql';
7
+
8
+ const getPath = (path, suffix) => {
9
+ if (path) {
10
+ return `/${path}${suffix || ''}`;
11
+ }
12
+
13
+ // If there is no path this is just a dead link.
14
+ return '#';
15
+ };
16
+
17
+ export const useShopByCategory = props => {
18
+ const { children, parent } = props;
19
+
20
+ const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
21
+ const { getStoreConfigQuery } = operations;
22
+
23
+ const { data: storeConfigData } = useQuery(getStoreConfigQuery, {
24
+ fetchPolicy: 'cache-and-network'
25
+ });
26
+
27
+ const categoryUrlSuffix = useMemo(() => {
28
+ if (storeConfigData) {
29
+ return storeConfigData.storeConfig.category_url_suffix;
30
+ }
31
+ }, [storeConfigData]);
32
+
33
+ const childrenNormalizedData = useMemo(() => {
34
+ if (children) {
35
+ return (
36
+ children.length &&
37
+ children
38
+ .map(category => ({
39
+ text: category.name,
40
+ path: getPath(
41
+ category.url_path,
42
+ categoryUrlSuffix
43
+ )
44
+ }))
45
+ );
46
+ }
47
+ }, [categoryUrlSuffix, children]);
48
+
49
+ const parentNormalizedData = useMemo(() => {
50
+ if (parent) {
51
+ return (
52
+ parent.length &&
53
+ parent
54
+ .map(category => ({
55
+ text: category.name,
56
+ path: getPath(
57
+ category.url_path,
58
+ categoryUrlSuffix
59
+ )
60
+ }))
61
+ );
62
+ }
63
+ }, [categoryUrlSuffix, parent]);
64
+
65
+ return {
66
+ childrenNormalizedData: childrenNormalizedData || [],
67
+ parentNormalizedData: parentNormalizedData || []
68
+ };
69
+ };
@@ -0,0 +1,15 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const GET_STORE_CONFIG_DATA = gql`
4
+ query GetStoreConfigForBreadcrumbs {
5
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
6
+ storeConfig {
7
+ store_code
8
+ category_url_suffix
9
+ }
10
+ }
11
+ `;
12
+
13
+ export default {
14
+ getStoreConfigQuery: GET_STORE_CONFIG_DATA
15
+ };
@@ -0,0 +1,52 @@
1
+ import { useMemo } from 'react';
2
+ import { useQuery } from '@apollo/client';
3
+
4
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
5
+
6
+ import DEFAULT_OPERATIONS from './subCategory.gql';
7
+
8
+ const getPath = (path, suffix) => {
9
+ if (path) {
10
+ return `/${path}${suffix || ''}`;
11
+ }
12
+
13
+ // If there is no path this is just a dead link.
14
+ return '#';
15
+ };
16
+
17
+ export const useSubCategory = props => {
18
+ const { children } = props;
19
+
20
+ const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
21
+ const { getStoreConfigQuery } = operations;
22
+
23
+ const { data: storeConfigData } = useQuery(getStoreConfigQuery, {
24
+ fetchPolicy: 'cache-and-network'
25
+ });
26
+
27
+ const categoryUrlSuffix = useMemo(() => {
28
+ if (storeConfigData) {
29
+ return storeConfigData.storeConfig.category_url_suffix;
30
+ }
31
+ }, [storeConfigData]);
32
+
33
+ const normalizedData = useMemo(() => {
34
+ if (children) {
35
+ return (
36
+ children.length &&
37
+ children
38
+ .map(category => ({
39
+ text: category.name,
40
+ path: getPath(
41
+ category.url_path,
42
+ categoryUrlSuffix
43
+ )
44
+ }))
45
+ );
46
+ }
47
+ }, [categoryUrlSuffix, children]);
48
+
49
+ return {
50
+ normalizedData: normalizedData || []
51
+ };
52
+ };