@riosst100/pwa-marketplace 2.4.9 → 2.5.1
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 +1 -1
- package/src/componentOverrideMapping.js +1 -0
- package/src/overwrites/peregrine/lib/store/actions/cart/asyncActions.js +0 -5
- package/src/overwrites/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js +77 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +9 -0
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ module.exports = componentOverrideMapping = {
|
|
|
7
7
|
[`@magento/peregrine/lib/talons/Adapter/useAdapter.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js',
|
|
8
8
|
[`@magento/peregrine/lib/talons/Header/useStoreSwitcher.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js',
|
|
9
9
|
[`@magento/peregrine/lib/talons/Header/storeSwitcher.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js',
|
|
10
|
+
[`@magento/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js',
|
|
10
11
|
[`@magento/peregrine/lib/talons/Region/useRegion.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Region/useRegion.js',
|
|
11
12
|
[`@magento/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql`]: '@riosst100/pwa-marketplace/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql',
|
|
12
13
|
[`@magento/peregrine/lib/store/actions/user/asyncActions.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js',
|
|
@@ -10,8 +10,6 @@ export const createSellerCart = payload =>
|
|
|
10
10
|
const { cart } = getState();
|
|
11
11
|
|
|
12
12
|
// Request a new cart.
|
|
13
|
-
dispatch(actions.getSellerCart.request());
|
|
14
|
-
|
|
15
13
|
try {
|
|
16
14
|
// errors can come from graphql and are not thrown
|
|
17
15
|
const { data, errors } = await initCheckoutSplitCart({
|
|
@@ -42,12 +40,9 @@ export const createSellerCart = payload =>
|
|
|
42
40
|
// write to storage in the background
|
|
43
41
|
saveSellerCartId(data.initCheckoutSplitCart.quote_id);
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
dispatch(actions.getSellerCart.receive(receivePayload));
|
|
47
43
|
} catch (error) {
|
|
48
44
|
// If we are unable to create a cart, the cart can't function, so
|
|
49
45
|
// we forcibly throw so the upstream actions won't retry.
|
|
50
|
-
dispatch(actions.getSellerCart.receive(error));
|
|
51
46
|
throw new Error('Unable to create seller cart');
|
|
52
47
|
}
|
|
53
48
|
};
|
package/src/overwrites/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const ProductListingFragment = gql`
|
|
4
|
+
fragment ProductListingFragment on Cart {
|
|
5
|
+
id
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
7
|
+
items {
|
|
8
|
+
uid
|
|
9
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
10
|
+
seller {
|
|
11
|
+
seller_name
|
|
12
|
+
seller_url
|
|
13
|
+
seller_id
|
|
14
|
+
}
|
|
15
|
+
product {
|
|
16
|
+
uid
|
|
17
|
+
name
|
|
18
|
+
sku
|
|
19
|
+
url_key
|
|
20
|
+
thumbnail {
|
|
21
|
+
url
|
|
22
|
+
}
|
|
23
|
+
small_image {
|
|
24
|
+
url
|
|
25
|
+
}
|
|
26
|
+
stock_status
|
|
27
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
28
|
+
... on ConfigurableProduct {
|
|
29
|
+
variants {
|
|
30
|
+
attributes {
|
|
31
|
+
uid
|
|
32
|
+
code
|
|
33
|
+
value_index
|
|
34
|
+
}
|
|
35
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
36
|
+
product {
|
|
37
|
+
uid
|
|
38
|
+
stock_status
|
|
39
|
+
small_image {
|
|
40
|
+
url
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
prices {
|
|
47
|
+
price {
|
|
48
|
+
currency
|
|
49
|
+
value
|
|
50
|
+
}
|
|
51
|
+
row_total {
|
|
52
|
+
value
|
|
53
|
+
}
|
|
54
|
+
total_item_discount {
|
|
55
|
+
value
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
quantity
|
|
59
|
+
errors {
|
|
60
|
+
code
|
|
61
|
+
message
|
|
62
|
+
}
|
|
63
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
64
|
+
... on ConfigurableCartItem {
|
|
65
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
66
|
+
configurable_options {
|
|
67
|
+
id
|
|
68
|
+
configurable_product_option_uid
|
|
69
|
+
option_label
|
|
70
|
+
configurable_product_option_value_uid
|
|
71
|
+
value_label
|
|
72
|
+
value_id
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
@@ -58,6 +58,9 @@ const ProductListing = props => {
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
console.log('items')
|
|
62
|
+
console.log(items)
|
|
63
|
+
|
|
61
64
|
// Grouping berdasarkan seller_id dengan data seller di atas
|
|
62
65
|
const groupedItems = items.reduce((acc, item) => {
|
|
63
66
|
if (!item.seller) {
|
|
@@ -80,10 +83,16 @@ const ProductListing = props => {
|
|
|
80
83
|
acc[seller_id].items.push(item);
|
|
81
84
|
return acc;
|
|
82
85
|
}, {});
|
|
86
|
+
|
|
87
|
+
console.log('groupedItems')
|
|
88
|
+
console.log(groupedItems)
|
|
83
89
|
|
|
84
90
|
// Ubah hasil ke dalam array
|
|
85
91
|
const itemsBySeller = Object.values(groupedItems);
|
|
86
92
|
|
|
93
|
+
console.log('itemsBySeller != []')
|
|
94
|
+
console.log(itemsBySeller)
|
|
95
|
+
|
|
87
96
|
if (itemsBySeller.length) {
|
|
88
97
|
const productBySellerComponents = itemsBySeller.map((sellerItems, index) => (
|
|
89
98
|
<ProductListingBySeller
|