@riosst100/pwa-marketplace 1.2.4 → 1.2.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.
Files changed (61) hide show
  1. package/package.json +1 -1
  2. package/src/components/OperatingHours/index.js +1 -0
  3. package/src/components/OperatingHours/operatingHours.js +32 -0
  4. package/src/components/Seller/seller.js +2 -119
  5. package/src/components/Seller/sellerAddressCard.js +48 -0
  6. package/src/components/SellerDetail/index.js +1 -0
  7. package/src/components/SellerDetail/sellerDetail.js +158 -0
  8. package/src/components/SellerInformation/sellerInformation.js +20 -29
  9. package/src/components/SellerLocation/sellerLocation.js +4 -5
  10. package/src/components/SellerLocation/sellerLocationItem.js +6 -8
  11. package/src/components/SellerProducts/sellerProducts.js +212 -40
  12. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -0
  13. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -0
  14. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -0
  15. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -0
  16. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -0
  17. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -0
  18. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -0
  19. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -0
  20. package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -0
  21. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -0
  22. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -0
  23. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -0
  24. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +31 -0
  25. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -0
  26. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +43 -0
  27. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -0
  28. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -0
  29. package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -0
  30. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -0
  31. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -0
  32. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -0
  33. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -0
  34. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -0
  35. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -0
  36. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -0
  37. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -0
  38. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -0
  39. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -0
  40. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -0
  41. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -0
  42. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -0
  43. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -0
  44. package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -0
  45. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -0
  46. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +50 -0
  47. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -0
  48. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -0
  49. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -0
  50. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -0
  51. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.module.css +0 -0
  52. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -0
  53. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -0
  54. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -0
  55. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -0
  56. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -0
  57. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -0
  58. package/src/talons/Seller/seller.gql.js +70 -5
  59. package/src/talons/Seller/useSeller.js +6 -1
  60. package/src/talons/SellerProducts/useSellerProducts.js +129 -0
  61. package/src/theme/vars.js +7 -0
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import { func, number, shape, string } from 'prop-types';
3
+ import { Link } from 'react-router-dom';
4
+ import Price from '@magento/venia-ui/lib/components/Price';
5
+ import { useStyle } from '@magento/venia-ui/lib/classify';
6
+
7
+ import Image from '@magento/venia-ui/lib/components/Image';
8
+ import defaultClasses from './suggestedProduct.module.css';
9
+ import { useSuggestedProduct } from '@magento/peregrine/lib/talons/SearchBar';
10
+
11
+ const IMAGE_WIDTH = 60;
12
+
13
+ const SuggestedProduct = props => {
14
+ const classes = useStyle(defaultClasses, props.classes);
15
+ const {
16
+ url_key,
17
+ small_image,
18
+ name,
19
+ onNavigate,
20
+ price,
21
+ price_range,
22
+ url_suffix,
23
+ sku
24
+ } = props;
25
+
26
+ const talonProps = useSuggestedProduct({
27
+ name,
28
+ price,
29
+ price_range,
30
+ onNavigate,
31
+ url_key,
32
+ url_suffix,
33
+ sku
34
+ });
35
+
36
+ const { priceProps, handleClick, uri } = talonProps;
37
+
38
+ return (
39
+ <Link
40
+ className={classes.root}
41
+ to={uri}
42
+ onClick={handleClick}
43
+ data-cy="SuggestedProduct-root"
44
+ >
45
+ <Image
46
+ alt={name}
47
+ classes={{ image: classes.thumbnail, root: classes.image }}
48
+ resource={small_image}
49
+ width={IMAGE_WIDTH}
50
+ data-cy="SuggestedProduct-image"
51
+ />
52
+ <span className={classes.name}>{name}</span>
53
+ <span data-cy="SuggestedProduct-price" className={classes.price}>
54
+ <Price {...priceProps} />
55
+ </span>
56
+ </Link>
57
+ );
58
+ };
59
+
60
+ SuggestedProduct.propTypes = {
61
+ url_key: string.isRequired,
62
+ small_image: string.isRequired,
63
+ name: string.isRequired,
64
+ onNavigate: func,
65
+ price: shape({
66
+ regularPrice: shape({
67
+ amount: shape({
68
+ currency: string,
69
+ value: number
70
+ })
71
+ })
72
+ }).isRequired,
73
+ price_range: shape({
74
+ maximum_price: shape({
75
+ final_price: shape({
76
+ currency: string,
77
+ value: number
78
+ }),
79
+ regular_price: shape({
80
+ currency: string,
81
+ value: number
82
+ }),
83
+ discount: shape({
84
+ amount_off: number
85
+ })
86
+ })
87
+ }),
88
+ classes: shape({
89
+ root: string,
90
+ image: string,
91
+ name: string,
92
+ price: string,
93
+ thumbnail: string
94
+ })
95
+ };
96
+
97
+ export default SuggestedProduct;
@@ -0,0 +1,24 @@
1
+ .root {
2
+ composes: gap-xs from global;
3
+ composes: grid from global;
4
+ composes: grid-flow-col from global;
5
+ composes: items-center from global;
6
+ grid-template-columns: 60px 1fr;
7
+ }
8
+
9
+ .image {
10
+ composes: items-center from global;
11
+ composes: inline-flex from global;
12
+ composes: justify-center from global;
13
+ }
14
+
15
+ .thumbnail {
16
+ composes: h-[75px] from global;
17
+ composes: max-h-[75px] from global;
18
+ composes: object-contain from global;
19
+ composes: object-center from global;
20
+ }
21
+
22
+ .name {
23
+ composes: break-words from global;
24
+ }
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { arrayOf, func, number, oneOfType, shape, string } from 'prop-types';
3
+
4
+ import { useStyle } from '@magento/venia-ui/lib/classify';
5
+ import mapProduct from '@magento/venia-ui/lib/util/mapProduct';
6
+ import SuggestedProduct from './suggestedProduct';
7
+ import defaultClasses from './suggestedProducts.module.css';
8
+
9
+ const SuggestedProducts = props => {
10
+ const { limit, onNavigate, products } = props;
11
+ const classes = useStyle(defaultClasses, props.classes);
12
+
13
+ const items = products.slice(0, limit).map(product => (
14
+ <li key={product.id} className={classes.item}>
15
+ <SuggestedProduct
16
+ {...mapProduct(product)}
17
+ onNavigate={onNavigate}
18
+ />
19
+ </li>
20
+ ));
21
+
22
+ return <ul className={classes.root}>{items}</ul>;
23
+ };
24
+
25
+ export default SuggestedProducts;
26
+
27
+ SuggestedProducts.defaultProps = {
28
+ limit: 3
29
+ };
30
+
31
+ SuggestedProducts.propTypes = {
32
+ classes: shape({
33
+ item: string,
34
+ root: string
35
+ }),
36
+ limit: number.isRequired,
37
+ onNavigate: func,
38
+ products: arrayOf(
39
+ shape({
40
+ id: oneOfType([number, string]).isRequired
41
+ })
42
+ ).isRequired
43
+ };
@@ -0,0 +1,13 @@
1
+ .products {
2
+ composes: border-t from global;
3
+ composes: border-solid from global;
4
+ composes: border-subtle from global;
5
+ composes: gap-3 from global;
6
+ composes: grid from global;
7
+ composes: pt-3 from global;
8
+ }
9
+
10
+ /* TODO @TW: cannot compose */
11
+ .products:empty {
12
+ display: none;
13
+ }
@@ -0,0 +1,75 @@
1
+ import React, { Fragment } from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { arrayOf, bool, func, shape, string } from 'prop-types';
4
+ import { useSuggestions } from '@magento/peregrine/lib/talons/SearchBar';
5
+
6
+ import { useStyle } from '@magento/venia-ui/lib/classify';
7
+ import SuggestedCategories from './suggestedCategories';
8
+ import SuggestedProducts from './suggestedProducts';
9
+ import defaultClasses from './suggestions.module.css';
10
+
11
+ const Suggestions = props => {
12
+ const {
13
+ displayResult,
14
+ filters,
15
+ products,
16
+ searchValue,
17
+ setVisible,
18
+ visible
19
+ } = props;
20
+ const { items } = products;
21
+
22
+ const talonProps = useSuggestions({
23
+ displayResult,
24
+ filters,
25
+ items,
26
+ setVisible,
27
+ visible
28
+ });
29
+ const { categories, onNavigate, shouldRender } = talonProps;
30
+ const classes = useStyle(defaultClasses, props.classes);
31
+
32
+ // render null without data
33
+ if (!shouldRender) {
34
+ return null;
35
+ }
36
+
37
+ return (
38
+ <Fragment>
39
+ <SuggestedCategories
40
+ categories={categories}
41
+ onNavigate={onNavigate}
42
+ value={searchValue}
43
+ />
44
+ <h2 data-cy="Suggestions-heading" className={classes.heading}>
45
+ <span>
46
+ <FormattedMessage
47
+ id={'searchBar.heading'}
48
+ defaultMessage={'Product Suggestions'}
49
+ />
50
+ </span>
51
+ </h2>
52
+ <SuggestedProducts onNavigate={onNavigate} products={items} />
53
+ </Fragment>
54
+ );
55
+ };
56
+
57
+ export default Suggestions;
58
+
59
+ Suggestions.propTypes = {
60
+ classes: shape({
61
+ heading: string
62
+ }),
63
+ products: shape({
64
+ filters: arrayOf(
65
+ shape({
66
+ filter_items: arrayOf(shape({})),
67
+ name: string.isRequired
68
+ }).isRequired
69
+ ),
70
+ items: arrayOf(shape({}))
71
+ }),
72
+ searchValue: string,
73
+ setVisible: func,
74
+ visible: bool
75
+ };
@@ -0,0 +1,6 @@
1
+ .heading {
2
+ composes: pt-3 from global;
3
+ composes: text-sm from global;
4
+ composes: text-subtle from global;
5
+ composes: uppercase from global;
6
+ }
@@ -11,8 +11,8 @@ export const GET_STORE_CONFIG_DATA = gql`
11
11
  `;
12
12
 
13
13
  export const GET_SELLER_DETAIL_QUERY = gql`
14
- query getSellerDetailForSellerPage($urlKey: String!) {
15
- sellerByUrl(seller_url: $urlKey) {
14
+ query getSellerDetailForSellerPage($urlKey: String!, $getOtherInfo: Boolean, $getProducts: Boolean) {
15
+ sellerByUrl(seller_url: $urlKey, get_other_info: $getOtherInfo, get_products: $getProducts) {
16
16
  seller_id
17
17
  contact_number
18
18
  shop_title
@@ -21,15 +21,81 @@ export const GET_SELLER_DETAIL_QUERY = gql`
21
21
  website_url
22
22
  ship_to
23
23
  ship_to_country
24
+ seller_rates {
25
+ total_count
26
+ page_info {
27
+ current_page
28
+ page_size
29
+ total_pages
30
+ }
31
+ items {
32
+ rating_id
33
+ seller_id
34
+ customer_id
35
+ rate1
36
+ rate2
37
+ rate3
38
+ rate4
39
+ rate5
40
+ rating
41
+ email
42
+ title
43
+ status
44
+ detail
45
+ nickname
46
+ created_at
47
+ verified_buyer
48
+ is_recommended
49
+ is_hidden
50
+ answer
51
+ admin_note
52
+ like_about
53
+ not_like_about
54
+ guest_email
55
+ plus_review
56
+ minus_review
57
+ report_abuse
58
+ country
59
+ }
60
+ }
61
+ products {
62
+ total_count
63
+ page_info {
64
+ current_page
65
+ page_size
66
+ total_pages
67
+ }
68
+ items {
69
+ name
70
+ sku
71
+ }
72
+ }
24
73
  operating_hours {
25
74
  day
75
+ status
26
76
  time {
27
77
  opening_time
28
78
  closing_time
29
79
  }
30
80
  }
81
+ store_locators {
82
+ name
83
+ country
84
+ region
85
+ address_line_1
86
+ address_line_2
87
+ city
88
+ postcode
89
+ operating_hours {
90
+ day
91
+ status
92
+ time {
93
+ opening_time
94
+ closing_time
95
+ }
96
+ }
97
+ }
31
98
  description
32
- address
33
99
  country
34
100
  image
35
101
  thumbnail
@@ -38,11 +104,10 @@ export const GET_SELLER_DETAIL_QUERY = gql`
38
104
  group
39
105
  group_id
40
106
  url
41
- customer_id
42
107
  email
43
108
  name
44
109
  sale
45
- commission_id
110
+ creation_time
46
111
  page_layout
47
112
  status
48
113
  position
@@ -28,12 +28,17 @@ export const useSeller = props => {
28
28
  const productUrlSuffix = storeConfigData?.storeConfig?.product_url_suffix;
29
29
  const urlKey = productUrlSuffix ? slug.replace(productUrlSuffix, '') : slug;
30
30
 
31
+ const getOtherInfo = true;
32
+ const getProducts = true;
33
+
31
34
  const { error, loading, data } = useQuery(getSellerDetailQuery, {
32
35
  fetchPolicy: 'cache-and-network',
33
36
  nextFetchPolicy: 'cache-first',
34
37
  skip: !storeConfigData,
35
38
  variables: {
36
- urlKey
39
+ urlKey,
40
+ getOtherInfo,
41
+ getProducts
37
42
  }
38
43
  });
39
44
 
@@ -0,0 +1,129 @@
1
+ import { useEffect } from 'react';
2
+ import { useLazyQuery, useQuery } from '@apollo/client';
3
+
4
+ import mergeOperations from '../../../util/shallowMerge';
5
+ import { useEventingContext } from '../../../context/eventing';
6
+
7
+ import DEFAULT_OPERATIONS from './categoryContent.gql';
8
+
9
+ /**
10
+ * Returns props necessary to render the categoryContent component.
11
+ *
12
+ * @param {object} props.data - The results of a getCategory GraphQL query.
13
+ *
14
+ * @returns {object} result
15
+ * @returns {string} result.categoryDescription - This category's description.
16
+ * @returns {string} result.categoryName - This category's name.
17
+ * @returns {object} result.filters - The filters object.
18
+ * @returns {object} result.items - The items in this category.
19
+ * @returns {number} result.totalPagesFromData - The total amount of pages for the query.
20
+ */
21
+ export const useSellerProducts = props => {
22
+ const { categoryId, data, pageSize = 6 } = props;
23
+
24
+ const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
25
+
26
+ const {
27
+ getSellerProductsQuery,
28
+ getProductFiltersByCategoryQuery,
29
+ getCategoryAvailableSortMethodsQuery
30
+ } = operations;
31
+
32
+ const placeholderItems = Array.from({ length: pageSize }).fill(null);
33
+
34
+ const [getFilters, { data: filterData }] = useLazyQuery(
35
+ getProductFiltersByCategoryQuery,
36
+ {
37
+ fetchPolicy: 'cache-and-network',
38
+ nextFetchPolicy: 'cache-first'
39
+ }
40
+ );
41
+
42
+ const [getSortMethods, { data: sortData }] = useLazyQuery(
43
+ getCategoryAvailableSortMethodsQuery,
44
+ {
45
+ fetchPolicy: 'cache-and-network',
46
+ nextFetchPolicy: 'cache-first'
47
+ }
48
+ );
49
+
50
+ const { data: categoryData, loading: categoryLoading } = useQuery(
51
+ getSellerProductsQuery,
52
+ {
53
+ fetchPolicy: 'cache-and-network',
54
+ nextFetchPolicy: 'cache-first',
55
+ skip: !categoryId,
56
+ variables: {
57
+ id: categoryId
58
+ }
59
+ }
60
+ );
61
+
62
+ const [, { dispatch }] = useEventingContext();
63
+
64
+ useEffect(() => {
65
+ if (categoryId) {
66
+ getFilters({
67
+ variables: {
68
+ categoryIdFilter: {
69
+ eq: categoryId
70
+ }
71
+ }
72
+ });
73
+ }
74
+ }, [categoryId, getFilters]);
75
+
76
+ useEffect(() => {
77
+ if (categoryId) {
78
+ getSortMethods({
79
+ variables: {
80
+ categoryIdFilter: {
81
+ in: categoryId
82
+ }
83
+ }
84
+ });
85
+ }
86
+ }, [categoryId, getSortMethods]);
87
+
88
+ const filters = filterData ? filterData.products.aggregations : null;
89
+ const items = data ? data.products.items : placeholderItems;
90
+ const totalPagesFromData = data
91
+ ? data.products.page_info.total_pages
92
+ : null;
93
+ const totalCount = data ? data.products.total_count : null;
94
+ const categoryName =
95
+ categoryData && categoryData.categories.items.length
96
+ ? categoryData.categories.items[0].name
97
+ : null;
98
+ const categoryDescription =
99
+ categoryData && categoryData.categories.items.length
100
+ ? categoryData.categories.items[0].description
101
+ : null;
102
+ const availableSortMethods = sortData
103
+ ? sortData.products.sort_fields.options
104
+ : null;
105
+
106
+ useEffect(() => {
107
+ if (!categoryLoading && categoryData.categories.items.length > 0) {
108
+ dispatch({
109
+ type: 'CATEGORY_PAGE_VIEW',
110
+ payload: {
111
+ id: categoryData.categories.items[0].uid,
112
+ name: categoryData.categories.items[0].name,
113
+ url_key: categoryData.categories.items[0].url_key,
114
+ url_path: categoryData.categories.items[0].url_path
115
+ }
116
+ });
117
+ }
118
+ }, [categoryData, dispatch, categoryLoading]);
119
+
120
+ return {
121
+ availableSortMethods,
122
+ categoryName,
123
+ categoryDescription,
124
+ filters,
125
+ items,
126
+ totalCount,
127
+ totalPagesFromData
128
+ };
129
+ };
@@ -0,0 +1,7 @@
1
+ export const textPrimary = '#1B1B1B';
2
+ export const lightGray = '#E6E9EA';
3
+
4
+ export default {
5
+ textPrimary,
6
+ lightGray,
7
+ }