@riosst100/pwa-marketplace 2.4.5 → 2.4.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 (26) hide show
  1. package/i18n/en_US.json +509 -508
  2. package/i18n/id_ID.json +1 -1
  3. package/package.json +1 -1
  4. package/src/componentOverrideMapping.js +1 -0
  5. package/src/components/SellerProducts/productContent.js +13 -0
  6. package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/priceSummary.gql.js +42 -0
  7. package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary.js +170 -0
  8. package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +0 -5
  9. package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +10 -0
  10. package/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.js +6 -75
  11. package/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.module.css +4 -2
  12. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/product.js +1 -1
  13. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/product.module.css +1 -1
  14. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +45 -24
  15. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/index.js +1 -0
  16. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/product.js +278 -0
  17. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/product.module.css +156 -0
  18. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/productListingBySeller.js +125 -0
  19. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/productListingBySeller.module.css +33 -0
  20. package/src/overwrites/venia-ui/lib/components/CartPage/cartPage.js +11 -8
  21. package/src/overwrites/venia-ui/lib/components/CartPage/cartPage.module.css +1 -1
  22. package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.js +12 -11
  23. package/src/talons/CartPage/ProductListingBySeller/checkoutBySeller.gql.js +21 -0
  24. package/src/talons/CartPage/ProductListingBySeller/useProductListingBySeller.js +73 -0
  25. package/src/talons/SellerProducts/useProductContent.js +25 -20
  26. package/src/talons/SellerProducts/useSellerProducts.js +1 -1
@@ -12,6 +12,8 @@ import { GET_ITEM_COUNT_QUERY } from '@magento/venia-ui/lib/components/Header/ca
12
12
  import cn from 'classnames';
13
13
  import { ShoppingCart } from 'iconsax-react';
14
14
  import { darkBlue } from '@riosst100/pwa-marketplace/src/theme/vars';
15
+ import { Link } from 'react-router-dom';
16
+ import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
15
17
 
16
18
  const MiniCart = React.lazy(() => import('@magento/venia-ui/lib/components/MiniCart'));
17
19
 
@@ -50,8 +52,8 @@ const CartTrigger = props => {
50
52
  <span
51
53
  className={cn(
52
54
  classes.counter,
53
- 'bg-yellow-300 min-w-[18px] min-h-[18px] text-base font-regular leading-[18px] top-[-5px]',
54
- '!left-auto right-[0px]'
55
+ 'bg-yellow-300 min-w-[18px] min-h-[18px] text-base font-regular leading-[18px] top-[-2px]',
56
+ '!left-auto right-[3px]'
55
57
  )}
56
58
  data-cy="CartTrigger-counter"
57
59
  >
@@ -65,20 +67,19 @@ const CartTrigger = props => {
65
67
  // and control which one displays via CSS.
66
68
  <Fragment>
67
69
  <div className={cn(triggerClassName, '!h-auto')} ref={miniCartTriggerRef}>
68
- <button
69
- aria-expanded={miniCartIsOpen}
70
- aria-label={buttonAriaLabel}
70
+ <Link
71
71
  className={cn(
72
72
  classes.trigger,
73
73
  'gap-[5px] !min-h-[30px] !h-auto !min-w-[35px] !w-fit !justify-between',
74
74
  )}
75
- onClick={handleTriggerClick}
76
- data-cy="CartTrigger-trigger"
75
+ to='/cart'
77
76
  >
78
- {/* <Icon src={ShoppingCartIcon} /> */}
79
- <ShoppingCart size="20" color={darkBlue} className={cn('stroke-0')} variant="Outline" />
80
- {maybeItemCounter}
81
- </button>
77
+ <span>
78
+ {/* <Icon src={ShoppingCartIcon} /> */}
79
+ <ShoppingCart size="20" color={darkBlue} className={cn('stroke-0')} variant="Outline" />
80
+ {maybeItemCounter}
81
+ </span>
82
+ </Link>
82
83
  </div>
83
84
  <button
84
85
  aria-expanded={miniCartIsOpen}
@@ -0,0 +1,21 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const INIT_CHECKOUT_SPLIT_CART_MUTATION = gql`
4
+ mutation InitCheckoutSplitCart(
5
+ $input: SubmitSplitCartInput!
6
+ ) {
7
+ initCheckoutSplitCart(
8
+ input: $input
9
+ ) {
10
+ id
11
+ parent_id
12
+ quote_id
13
+ is_active
14
+ is_ordered
15
+ }
16
+ }
17
+ `;
18
+
19
+ export default {
20
+ initCheckoutSplitCartMutation: INIT_CHECKOUT_SPLIT_CART_MUTATION
21
+ };
@@ -0,0 +1,73 @@
1
+ import { useCallback, useMemo, useState, useEffect } from 'react';
2
+ import { useFieldApi } from 'informed';
3
+ import useFieldState from '@magento/peregrine/lib/hooks/hook-wrappers/useInformedFieldStateWrapper';
4
+ import debounce from 'lodash.debounce';
5
+ import { useEventingContext } from '@magento/peregrine/lib/context/eventing';
6
+ import { useMutation } from '@apollo/client';
7
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
8
+ import DEFAULT_OPERATIONS from '@riosst100/pwa-marketplace/src/talons/CartPage/ProductListingBySeller/checkoutBySeller.gql';
9
+
10
+ export const useProductListingBySeller = props => {
11
+ const { initialValue, min, onChange } = props;
12
+
13
+ const operations = mergeOperations(DEFAULT_OPERATIONS, null);
14
+ const {
15
+ initCheckoutSplitCartMutation
16
+ } = operations;
17
+
18
+ const [
19
+ initCheckoutSplitCart,
20
+ {
21
+ loading: initCheckoutSplitCartLoading,
22
+ error: initCheckoutSplitCartError,
23
+ called: initCheckoutSplitCartCalled
24
+ }
25
+ ] = useMutation(initCheckoutSplitCartMutation);
26
+
27
+ const [displayError, setDisplayError] = useState(false);
28
+
29
+ const [, { dispatch }] = useEventingContext();
30
+
31
+ const handleSellerToCheckout = useCallback(
32
+ async (sellerUrl, cartId) => {
33
+ try {
34
+ // await initCheckoutSplitCart({
35
+ // variables: {
36
+ // seller_url: sellerUrl,
37
+ // cart_id: cartId
38
+ // }
39
+ // });
40
+
41
+ // const selectedOptions =
42
+ // item.configurable_options?.map(
43
+ // ({ option_label, value_label }) => ({
44
+ // attribute: option_label,
45
+ // value: value_label
46
+ // })
47
+ // ) || null;
48
+
49
+ // dispatch({
50
+ // type: quantity ? 'CART_UPDATE_ITEM' : 'CART_REMOVE_ITEM',
51
+ // payload: {
52
+ // cartId,
53
+ // sku: item.product.sku,
54
+ // name: item.product.name,
55
+ // priceTotal: item.prices.price.value,
56
+ // currencyCode: item.prices.price.currency,
57
+ // discountAmount: item.prices.total_item_discount.value,
58
+ // selectedOptions,
59
+ // quantity: quantity || item.quantity
60
+ // }
61
+ // });
62
+ } catch (err) {
63
+ // Make sure any errors from the mutation are displayed.
64
+ setDisplayError(true);
65
+ }
66
+ },
67
+ [dispatch, initCheckoutSplitCart]
68
+ );
69
+
70
+ return {
71
+ handleSellerToCheckout
72
+ };
73
+ };
@@ -9,6 +9,8 @@ import DEFAULT_OPERATIONS from './productContent.gql';
9
9
  export const useProductContent = props => {
10
10
  const { sellerId, data, pageSize = 6 } = props;
11
11
 
12
+ const categoryUid = 'MTI=';
13
+
12
14
  const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
13
15
 
14
16
  const {
@@ -56,9 +58,9 @@ export const useProductContent = props => {
56
58
  {
57
59
  fetchPolicy: 'cache-and-network',
58
60
  nextFetchPolicy: 'cache-first',
59
- skip: !sellerId,
61
+ skip: !categoryUid,
60
62
  variables: {
61
- id: sellerId
63
+ id: categoryUid
62
64
  }
63
65
  }
64
66
  );
@@ -66,47 +68,50 @@ export const useProductContent = props => {
66
68
  const [, { dispatch }] = useEventingContext();
67
69
 
68
70
  useEffect(() => {
69
- if (sellerId) {
71
+ if (categoryUid) {
70
72
  getFilters({
71
73
  variables: {
72
74
  categoryIdFilter: {
73
- eq: sellerId
75
+ eq: categoryUid
74
76
  }
75
77
  }
76
78
  });
77
79
  }
78
- }, [sellerId, getFilters]);
80
+ }, [categoryUid, getFilters]);
79
81
 
80
82
  useEffect(() => {
81
- if (sellerId) {
83
+ if (categoryUid) {
82
84
  getSortMethods({
83
85
  variables: {
84
86
  categoryIdFilter: {
85
- in: sellerId
87
+ in: categoryUid
86
88
  }
87
89
  }
88
90
  });
89
91
  }
90
- }, [sellerId, getSortMethods]);
92
+ }, [categoryUid, getSortMethods]);
91
93
 
92
- // console.log('data')
93
- // console.log(data)
94
+ console.log('filterData')
95
+ console.log(filterData)
94
96
 
95
97
  const rawFilters = filterData ? filterData.products.aggregations : null;
96
98
  const items = data ? data.items : placeholderItems;
97
- const category = null;
98
- const children = null;
99
- // const category =
100
- // categoryData && categoryData.categories.items.length
101
- // ? categoryData.categories.items[0]
102
- // : null;
103
- // const children =
104
- // categoryData && categoryData.categories.items.length
105
- // ? categoryData.categories.items[0].children
106
- // : null;
99
+ // const category = null;
100
+ // const children = null;
101
+ const category =
102
+ categoryData && categoryData.categories.items.length
103
+ ? categoryData.categories.items[0]
104
+ : null;
105
+ const children =
106
+ categoryData && categoryData.categories.items.length
107
+ ? categoryData.categories.items[0].children
108
+ : null;
107
109
 
108
110
  const filters = [];
109
111
 
112
+ console.log('rawFilters')
113
+ console.log(rawFilters)
114
+
110
115
  rawFilters && rawFilters.map((filter, index) => {
111
116
 
112
117
  const filterOptions = [];
@@ -132,7 +132,7 @@ export const useSellerProducts = props => {
132
132
  const categoryId = useMemo(() => {
133
133
  let uid = null;
134
134
  if (categoryData) {
135
- uid = categoryData.categories.items[0].id;
135
+ uid = categoryData?.categories?.items[0].id;
136
136
  }
137
137
  return uid;
138
138
  }, [categoryData]);