@riosst100/pwa-marketplace 2.4.4 → 2.4.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/i18n/en_US.json +509 -508
- package/i18n/id_ID.json +1 -1
- package/package.json +1 -1
- package/src/componentOverrideMapping.js +1 -0
- package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/priceSummary.gql.js +42 -0
- package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary.js +170 -0
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +13 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.js +6 -75
- package/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.module.css +4 -2
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/product.js +1 -1
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/product.module.css +1 -1
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +45 -24
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/product.js +278 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/product.module.css +156 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/productListingBySeller.js +125 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/productListingBySeller.module.css +33 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/cartPage.js +11 -8
- package/src/overwrites/venia-ui/lib/components/CartPage/cartPage.module.css +1 -1
- package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.js +12 -11
- package/src/talons/CartPage/ProductListingBySeller/checkoutBySeller.gql.js +21 -0
- package/src/talons/CartPage/ProductListingBySeller/useProductListingBySeller.js +73 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
3
|
+
// import { Heart } from 'react-feather';
|
|
4
|
+
import { gql } from '@apollo/client';
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
import { useProduct } from '@magento/peregrine/lib/talons/CartPage/ProductListing/useProduct';
|
|
7
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
8
|
+
import Price from '@magento/venia-ui/lib/components/Price';
|
|
9
|
+
|
|
10
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
11
|
+
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
12
|
+
import Image from '@magento/venia-ui/lib/components/Image';
|
|
13
|
+
import Kebab from '@magento/venia-ui/lib/components/LegacyMiniCart/kebab';
|
|
14
|
+
import ProductOptions from '@magento/venia-ui/lib/components/LegacyMiniCart/productOptions';
|
|
15
|
+
import Section from '@magento/venia-ui/lib/components/LegacyMiniCart/section';
|
|
16
|
+
import AddToListButton from '@magento/venia-ui/lib/components/Wishlist/AddToListButton';
|
|
17
|
+
import Quantity from './quantity';
|
|
18
|
+
import cn from 'classnames';
|
|
19
|
+
import Button from '@magento/venia-ui/lib/components/Button';
|
|
20
|
+
import { Trash, Heart } from 'iconsax-react';
|
|
21
|
+
|
|
22
|
+
import defaultClasses from './product.module.css';
|
|
23
|
+
|
|
24
|
+
import { CartPageFragment } from '@magento/peregrine/lib/talons/CartPage/cartPageFragments.gql.js';
|
|
25
|
+
import { AvailableShippingMethodsCartFragment } from '@magento/peregrine/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethodsFragments.gql.js';
|
|
26
|
+
|
|
27
|
+
const IMAGE_SIZE = 100;
|
|
28
|
+
|
|
29
|
+
const HeartIcon = <Heart size="16" color="#909090" />;
|
|
30
|
+
|
|
31
|
+
const Product = props => {
|
|
32
|
+
const { item } = props;
|
|
33
|
+
|
|
34
|
+
const { formatMessage } = useIntl();
|
|
35
|
+
const talonProps = useProduct({
|
|
36
|
+
operations: {
|
|
37
|
+
removeItemMutation: REMOVE_ITEM_MUTATION,
|
|
38
|
+
updateItemQuantityMutation: UPDATE_QUANTITY_MUTATION
|
|
39
|
+
},
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
addToWishlistProps,
|
|
45
|
+
errorMessage,
|
|
46
|
+
handleEditItem,
|
|
47
|
+
handleRemoveFromCart,
|
|
48
|
+
handleUpdateItemQuantity,
|
|
49
|
+
isEditable,
|
|
50
|
+
product,
|
|
51
|
+
isProductUpdating
|
|
52
|
+
} = talonProps;
|
|
53
|
+
|
|
54
|
+
const { afterAdd, item: itemProduct, storeConfig } = addToWishlistProps;
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
currency,
|
|
58
|
+
image,
|
|
59
|
+
name,
|
|
60
|
+
options,
|
|
61
|
+
quantity,
|
|
62
|
+
stockStatus,
|
|
63
|
+
unitPrice,
|
|
64
|
+
urlKey,
|
|
65
|
+
urlSuffix
|
|
66
|
+
} = product;
|
|
67
|
+
|
|
68
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
69
|
+
|
|
70
|
+
const itemClassName = isProductUpdating
|
|
71
|
+
? classes.item_disabled
|
|
72
|
+
: classes.item;
|
|
73
|
+
|
|
74
|
+
const editItemSection = isEditable ? (
|
|
75
|
+
<Section
|
|
76
|
+
text={formatMessage({
|
|
77
|
+
id: 'product.editItem',
|
|
78
|
+
defaultMessage: 'Edit item'
|
|
79
|
+
})}
|
|
80
|
+
data-cy="Product-Section-editItem"
|
|
81
|
+
onClick={handleEditItem}
|
|
82
|
+
icon="Edit2"
|
|
83
|
+
classes={{
|
|
84
|
+
text: classes.sectionText
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
) : null;
|
|
88
|
+
|
|
89
|
+
const itemLink = useMemo(
|
|
90
|
+
() => resourceUrl(`/${urlKey}${urlSuffix || ''}`),
|
|
91
|
+
[urlKey, urlSuffix]
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const stockStatusMessage =
|
|
95
|
+
stockStatus === 'OUT_OF_STOCK'
|
|
96
|
+
? formatMessage({
|
|
97
|
+
id: 'product.outOfStock',
|
|
98
|
+
defaultMessage: 'Out-of-stock'
|
|
99
|
+
})
|
|
100
|
+
: '';
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<li className={cn(classes.root, 'border-b border-gray-100 p-[15px] last_border-none')} data-cy="Product-root">
|
|
104
|
+
<span className={classes.errorText}>{errorMessage}</span>
|
|
105
|
+
<div className="flex justify-between">
|
|
106
|
+
<div className='flex gap-[15px]'>
|
|
107
|
+
<Link
|
|
108
|
+
to={itemLink}
|
|
109
|
+
className={classes.imageContainer}
|
|
110
|
+
data-cy="Product-imageContainer"
|
|
111
|
+
>
|
|
112
|
+
<Image
|
|
113
|
+
alt={name}
|
|
114
|
+
classes={{
|
|
115
|
+
root: classes.imageRoot,
|
|
116
|
+
image: cn(classes.image, '!h-[100px] w-full border-gray-100 !rounded-md !bg-transparent p-1')
|
|
117
|
+
}}
|
|
118
|
+
width={IMAGE_SIZE}
|
|
119
|
+
height={IMAGE_SIZE}
|
|
120
|
+
resource={image}
|
|
121
|
+
data-cy="Product-image"
|
|
122
|
+
/>
|
|
123
|
+
</Link>
|
|
124
|
+
<div className='flex flex-col'>
|
|
125
|
+
<div className={cn(classes.name, 'text-[14px] font-normal max-w-[260px]')} data-cy="Product-name">
|
|
126
|
+
<Link to={itemLink}>{name}</Link>
|
|
127
|
+
</div>
|
|
128
|
+
<ProductOptions
|
|
129
|
+
options={options}
|
|
130
|
+
classes={{
|
|
131
|
+
options: classes.options,
|
|
132
|
+
optionLabel: classes.optionLabel
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
<span className={classes.stockStatusMessage}>
|
|
136
|
+
{stockStatusMessage}
|
|
137
|
+
</span>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
<div className="flex flex-col">
|
|
141
|
+
|
|
142
|
+
<span className={cn(classes.price, 'text-[16px] font-medium text-right mb-5')} data-cy="Product-price">
|
|
143
|
+
<Price currencyCode={currency} value={unitPrice} />
|
|
144
|
+
{/* <FormattedMessage
|
|
145
|
+
id={'product.price'}
|
|
146
|
+
defaultMessage={' ea.'}
|
|
147
|
+
/> */}
|
|
148
|
+
</span>
|
|
149
|
+
<div className={cn(classes.quantity, 'hidden sm_flex')}>
|
|
150
|
+
<Quantity
|
|
151
|
+
itemId={item.id}
|
|
152
|
+
initialValue={quantity}
|
|
153
|
+
onChange={handleUpdateItemQuantity}
|
|
154
|
+
/>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
{/* <Kebab
|
|
158
|
+
classes={{
|
|
159
|
+
root: classes.kebab
|
|
160
|
+
}}
|
|
161
|
+
disabled={true}
|
|
162
|
+
>
|
|
163
|
+
{editItemSection}
|
|
164
|
+
<Section
|
|
165
|
+
text={formatMessage({
|
|
166
|
+
id: 'product.removeFromCart',
|
|
167
|
+
defaultMessage: 'Remove from cart'
|
|
168
|
+
})}
|
|
169
|
+
data-cy="Product-Section-removeFromCart"
|
|
170
|
+
onClick={handleRemoveFromCart}
|
|
171
|
+
icon="Trash"
|
|
172
|
+
classes={{
|
|
173
|
+
text: classes.sectionText
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
<li>
|
|
177
|
+
<AddToListButton
|
|
178
|
+
{...addToWishlistProps}
|
|
179
|
+
classes={{
|
|
180
|
+
root: classes.addToListButton,
|
|
181
|
+
root_selected: classes.addToListButton_selected
|
|
182
|
+
}}
|
|
183
|
+
icon={HeartIcon}
|
|
184
|
+
/>
|
|
185
|
+
</li>
|
|
186
|
+
</Kebab> */}
|
|
187
|
+
|
|
188
|
+
</div>
|
|
189
|
+
<div className='flex justify-end gap-2.5 items-center mt-2 sm_mt-0'>
|
|
190
|
+
<div className={cn(classes.quantity, 'flex-auto sm_hidden')}>
|
|
191
|
+
<Quantity
|
|
192
|
+
itemId={item.id}
|
|
193
|
+
initialValue={quantity}
|
|
194
|
+
onChange={handleUpdateItemQuantity}
|
|
195
|
+
/>
|
|
196
|
+
</div>
|
|
197
|
+
{editItemSection}
|
|
198
|
+
<li>
|
|
199
|
+
<AddToListButton
|
|
200
|
+
// {...addToWishlistProps}
|
|
201
|
+
afterAdd={afterAdd}
|
|
202
|
+
item={itemProduct}
|
|
203
|
+
storeConfig={storeConfig}
|
|
204
|
+
classes={{
|
|
205
|
+
root: cn(
|
|
206
|
+
classes.addToListButton,
|
|
207
|
+
'min-w-min border border-gray-200 rounded-full border-solid w-7 h-7 flex items-center justify-center !p-0 hover_border-gray-600'
|
|
208
|
+
),
|
|
209
|
+
root_selected: classes.addToListButton_selected
|
|
210
|
+
}}
|
|
211
|
+
icon={HeartIcon}
|
|
212
|
+
/>
|
|
213
|
+
</li>
|
|
214
|
+
{/* <Section
|
|
215
|
+
// text={formatMessage({
|
|
216
|
+
// id: 'product.removeFromCart',
|
|
217
|
+
// defaultMessage: 'Remove from cart'
|
|
218
|
+
// })}
|
|
219
|
+
data-cy="Product-Section-removeFromCart"
|
|
220
|
+
onClick={handleRemoveFromCart}
|
|
221
|
+
icon={"Trash"}
|
|
222
|
+
classes={{
|
|
223
|
+
text: classes.sectionText,
|
|
224
|
+
button: 'w-fitContent'
|
|
225
|
+
}}
|
|
226
|
+
/> */}
|
|
227
|
+
<Button
|
|
228
|
+
data-cy="Product-Section-removeFromCart"
|
|
229
|
+
onClick={handleRemoveFromCart}
|
|
230
|
+
className="min-w-min border border-gray-200 rounded-full border-solid w-7 h-7 flex items-center justify-center hover_border-gray-600"
|
|
231
|
+
>
|
|
232
|
+
<Trash size="16" color="#999999" />
|
|
233
|
+
</Button>
|
|
234
|
+
</div>
|
|
235
|
+
</li>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export default Product;
|
|
240
|
+
|
|
241
|
+
export const REMOVE_ITEM_MUTATION = gql`
|
|
242
|
+
mutation removeItem($cartId: String!, $itemId: ID!) {
|
|
243
|
+
removeItemFromCart(
|
|
244
|
+
input: { cart_id: $cartId, cart_item_uid: $itemId }
|
|
245
|
+
) {
|
|
246
|
+
cart {
|
|
247
|
+
id
|
|
248
|
+
...CartPageFragment
|
|
249
|
+
...AvailableShippingMethodsCartFragment
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
${CartPageFragment}
|
|
254
|
+
${AvailableShippingMethodsCartFragment}
|
|
255
|
+
`;
|
|
256
|
+
|
|
257
|
+
export const UPDATE_QUANTITY_MUTATION = gql`
|
|
258
|
+
mutation updateItemQuantity(
|
|
259
|
+
$cartId: String!
|
|
260
|
+
$itemId: ID!
|
|
261
|
+
$quantity: Float!
|
|
262
|
+
) {
|
|
263
|
+
updateCartItems(
|
|
264
|
+
input: {
|
|
265
|
+
cart_id: $cartId
|
|
266
|
+
cart_items: [{ cart_item_uid: $itemId, quantity: $quantity }]
|
|
267
|
+
}
|
|
268
|
+
) {
|
|
269
|
+
cart {
|
|
270
|
+
id
|
|
271
|
+
...CartPageFragment
|
|
272
|
+
...AvailableShippingMethodsCartFragment
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
${CartPageFragment}
|
|
277
|
+
${AvailableShippingMethodsCartFragment}
|
|
278
|
+
`;
|
package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/product.module.css
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: gap-y-2xs from global;
|
|
3
|
+
composes: grid from global;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.item {
|
|
7
|
+
composes: gap-x-2xs from global;
|
|
8
|
+
composes: gap-y-xs from global;
|
|
9
|
+
composes: grid from global;
|
|
10
|
+
composes: items-start from global;
|
|
11
|
+
grid-template-areas: 'image details kebab';
|
|
12
|
+
grid-template-columns: 100px 1fr min-content;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.item_disabled {
|
|
16
|
+
composes: item;
|
|
17
|
+
composes: opacity-50 from global;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.errorText {
|
|
21
|
+
composes: leading-normal from global;
|
|
22
|
+
composes: text-error from global;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* TODO @TW: cannot compose */
|
|
26
|
+
.errorText:empty {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.imageContainer {
|
|
31
|
+
grid-area: image;
|
|
32
|
+
flex-basis: 100px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.imageRoot {
|
|
36
|
+
composes: h-full from global;
|
|
37
|
+
composes: w-[100px] from global;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.image {
|
|
41
|
+
composes: bg-subtle from global;
|
|
42
|
+
composes: border from global;
|
|
43
|
+
composes: border-solid from global;
|
|
44
|
+
composes: border-subtle from global;
|
|
45
|
+
composes: h-full from global;
|
|
46
|
+
composes: object-contain from global;
|
|
47
|
+
composes: object-center from global;
|
|
48
|
+
composes: rounded-sm from global;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.details {
|
|
52
|
+
composes: gap-2xs from global;
|
|
53
|
+
composes: leading-normal from global;
|
|
54
|
+
|
|
55
|
+
composes: sm_grid from global;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (min-width: 640px) {
|
|
59
|
+
.details {
|
|
60
|
+
grid-area: details;
|
|
61
|
+
grid-template-areas:
|
|
62
|
+
'name name'
|
|
63
|
+
'options quantity'
|
|
64
|
+
'price quantity'
|
|
65
|
+
'stock quantity';
|
|
66
|
+
grid-template-columns: 2fr 1fr;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.name {
|
|
71
|
+
/* composes: font-medium from global; */
|
|
72
|
+
grid-area: name;
|
|
73
|
+
display: -webkit-box;
|
|
74
|
+
-webkit-line-clamp: 2;
|
|
75
|
+
-webkit-box-orient: vertical;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
line-height: normal;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.price {
|
|
81
|
+
composes: text-sm from global;
|
|
82
|
+
grid-area: price;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.quantity {
|
|
86
|
+
composes: grid from global;
|
|
87
|
+
composes: items-start from global;
|
|
88
|
+
composes: justify-items-start from global;
|
|
89
|
+
grid-area: quantity;
|
|
90
|
+
|
|
91
|
+
composes: sm_justify-items-center from global;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.kebab {
|
|
95
|
+
composes: relative from global;
|
|
96
|
+
grid-area: kebab;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sectionText {
|
|
100
|
+
composes: pointer-events-none from global;
|
|
101
|
+
composes: px-2xs from global;
|
|
102
|
+
composes: py-1 from global;
|
|
103
|
+
composes: text-sm from global;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.options {
|
|
107
|
+
composes: gap-0.5 from global;
|
|
108
|
+
composes: grid from global;
|
|
109
|
+
composes: text-sm from global;
|
|
110
|
+
grid-area: options;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.optionLabel {
|
|
114
|
+
composes: auto-cols-max from global;
|
|
115
|
+
composes: grid from global;
|
|
116
|
+
composes: grid-flow-col from global;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.stockStatusMessage {
|
|
120
|
+
composes: font-medium from global;
|
|
121
|
+
composes: text-error from global;
|
|
122
|
+
composes: text-sm from global;
|
|
123
|
+
grid-area: stock;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* TODO @TW: cannot compose */
|
|
127
|
+
.stockStatusMessage:empty {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.addToListButton {
|
|
132
|
+
--stroke: rgb(var(--venia-global-color-teal));
|
|
133
|
+
|
|
134
|
+
composes: content-center from global;
|
|
135
|
+
composes: gap-x-xs from global;
|
|
136
|
+
composes: inline-flex from global;
|
|
137
|
+
composes: px-2.5 from global;
|
|
138
|
+
composes: py-3.5 from global;
|
|
139
|
+
composes: text-sm from global;
|
|
140
|
+
composes: w-full from global;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.addToListButton_selected {
|
|
144
|
+
composes: hidden from global;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@media (max-width: 639px) {
|
|
148
|
+
|
|
149
|
+
.name,
|
|
150
|
+
.options,
|
|
151
|
+
.price,
|
|
152
|
+
.stockStatusMessage,
|
|
153
|
+
.quantity {
|
|
154
|
+
grid-area: auto;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React, { Fragment, Suspense } from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
5
|
+
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import LoadingIndicator from '@magento/venia-ui/lib/components/LoadingIndicator';
|
|
8
|
+
import defaultClasses from './productListingBySeller.module.css';
|
|
9
|
+
import Product from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/product';
|
|
10
|
+
import ErrorMessage from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/errorMessage';
|
|
11
|
+
import cn from 'classnames';
|
|
12
|
+
import { useProductListingBySeller } from '@riosst100/pwa-marketplace/src/talons/CartPage/ProductListingBySeller/useProductListingBySeller';
|
|
13
|
+
import { Shop, ArrowRight2 } from 'iconsax-react';
|
|
14
|
+
import PriceSummary from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary';
|
|
15
|
+
|
|
16
|
+
const EditModal = React.lazy(() => import('@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/EditModal'));
|
|
17
|
+
/**
|
|
18
|
+
* A child component of the CartPage component.
|
|
19
|
+
* This component renders the product listing on the cart page.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} props
|
|
22
|
+
* @param {Function} props.setIsCartUpdating Function for setting the updating state of the cart.
|
|
23
|
+
* @param {Object} props.classes CSS className overrides.
|
|
24
|
+
* See [productListing.module.css]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/ProductListing/productListing.module.css}
|
|
25
|
+
* for a list of classes you can override.
|
|
26
|
+
*
|
|
27
|
+
* @returns {React.Element}
|
|
28
|
+
*
|
|
29
|
+
* @example <caption>Importing into your project</caption>
|
|
30
|
+
* import ProductListing from "@magento/venia-ui/lib/components/CartPage/ProductListing";
|
|
31
|
+
*/
|
|
32
|
+
const ProductListingBySeller = props => {
|
|
33
|
+
const {
|
|
34
|
+
onAddToWishlistSuccess,
|
|
35
|
+
isCartUpdating,
|
|
36
|
+
hasItems,
|
|
37
|
+
setIsCartUpdating,
|
|
38
|
+
fetchCartDetails,
|
|
39
|
+
activeEditItem,
|
|
40
|
+
setActiveEditItem,
|
|
41
|
+
wishlistConfig,
|
|
42
|
+
isLoading,
|
|
43
|
+
error,
|
|
44
|
+
seller,
|
|
45
|
+
items
|
|
46
|
+
} = props;
|
|
47
|
+
|
|
48
|
+
const talonProps = useProductListingBySeller({
|
|
49
|
+
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
handleSellerToCheckout
|
|
54
|
+
} = talonProps;
|
|
55
|
+
|
|
56
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
57
|
+
|
|
58
|
+
if (isLoading) {
|
|
59
|
+
return (
|
|
60
|
+
<LoadingIndicator>
|
|
61
|
+
<FormattedMessage
|
|
62
|
+
id={'productListing.loading'}
|
|
63
|
+
defaultMessage={'Fetching Cart...'}
|
|
64
|
+
/>
|
|
65
|
+
</LoadingIndicator>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (items.length) {
|
|
70
|
+
const productComponents = items.map(product => (
|
|
71
|
+
<Product
|
|
72
|
+
item={product}
|
|
73
|
+
key={product.uid}
|
|
74
|
+
setActiveEditItem={setActiveEditItem}
|
|
75
|
+
setIsCartUpdating={setIsCartUpdating}
|
|
76
|
+
onAddToWishlistSuccess={onAddToWishlistSuccess}
|
|
77
|
+
fetchCartDetails={fetchCartDetails}
|
|
78
|
+
wishlistConfig={wishlistConfig}
|
|
79
|
+
/>
|
|
80
|
+
));
|
|
81
|
+
|
|
82
|
+
const priceSummary = hasItems ? (
|
|
83
|
+
<PriceSummary isUpdating={isCartUpdating} sellerUrl={seller.seller_url} />
|
|
84
|
+
) : null;
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Fragment>
|
|
88
|
+
<ErrorMessage error={error} />
|
|
89
|
+
<ul className={cn(classes.root, 'mb-5 border border-gray-100 rounded-md')} data-cy="ProductListing-root">
|
|
90
|
+
<div className='px-6'>
|
|
91
|
+
<div className={cn(classes.sellerTitleContainer, 'border-b border-gray-100')}>
|
|
92
|
+
{/* <input type="checkbox" className={classes.sellerCheckbox} onChange={handleSellerToCheckout(seller.seller_url, null)}/> */}
|
|
93
|
+
<Link
|
|
94
|
+
to={resourceUrl('/seller/' + seller.seller_url)}
|
|
95
|
+
className={classes.seller_title}
|
|
96
|
+
><span style={{
|
|
97
|
+
"display": "flex",
|
|
98
|
+
"gap": "7px"
|
|
99
|
+
}}>
|
|
100
|
+
<span style={{"paddingTop": "2px"}}><Shop size="20" color="#999999" /></span>
|
|
101
|
+
{seller?.seller_name}<span style={{"paddingTop": "3px"}}><ArrowRight2 size="18" color="#999999" /></span></span></Link>
|
|
102
|
+
</div>
|
|
103
|
+
{productComponents}
|
|
104
|
+
<div className={classes.summary_container}>
|
|
105
|
+
<div className={classes.summary_contents}>
|
|
106
|
+
{priceSummary}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</ul>
|
|
111
|
+
<Suspense fallback={null}>
|
|
112
|
+
<EditModal
|
|
113
|
+
item={activeEditItem}
|
|
114
|
+
setIsCartUpdating={setIsCartUpdating}
|
|
115
|
+
setActiveEditItem={setActiveEditItem}
|
|
116
|
+
/>
|
|
117
|
+
</Suspense>
|
|
118
|
+
</Fragment>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default ProductListingBySeller;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: 1rem 0.5rem;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.errorText {
|
|
7
|
+
line-height: 1.5;
|
|
8
|
+
margin-bottom: 0.25rem;
|
|
9
|
+
color: #dc3545;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.seller_title {
|
|
13
|
+
font-weight: 500;
|
|
14
|
+
font-size: 16px;
|
|
15
|
+
/* padding-left: 10px; */
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.sellerTitleContainer {
|
|
19
|
+
display: block;
|
|
20
|
+
padding: 15px 0px 15px 0px;
|
|
21
|
+
border-bottom-width: 2px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.sellerCheckbox {
|
|
25
|
+
width: 19px;
|
|
26
|
+
height: 19px;
|
|
27
|
+
vertical-align: text-bottom;
|
|
28
|
+
/* appearance: none; */
|
|
29
|
+
border: 1px solid #d7d7d7;
|
|
30
|
+
border-radius: 5px;
|
|
31
|
+
/* outline: none; */
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
@@ -62,11 +62,17 @@ const CartPage = props => {
|
|
|
62
62
|
return fullPageLoadingIndicator;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
const priceSummary = hasItems ? (
|
|
66
|
+
<PriceSummary isUpdating={isCartUpdating} />
|
|
67
|
+
) : null;
|
|
68
|
+
|
|
65
69
|
const productListing = hasItems ? (
|
|
66
70
|
<ProductListing
|
|
67
71
|
onAddToWishlistSuccess={onAddToWishlistSuccess}
|
|
68
72
|
setIsCartUpdating={setIsCartUpdating}
|
|
69
73
|
fetchCartDetails={fetchCartDetails}
|
|
74
|
+
isCartUpdating={isCartUpdating}
|
|
75
|
+
hasItems={hasItems}
|
|
70
76
|
/>
|
|
71
77
|
) : (
|
|
72
78
|
<h3>
|
|
@@ -81,10 +87,7 @@ const CartPage = props => {
|
|
|
81
87
|
<PriceAdjustments setIsCartUpdating={setIsCartUpdating} />
|
|
82
88
|
) : null;
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
<PriceSummary isUpdating={isCartUpdating} />
|
|
86
|
-
) : null;
|
|
87
|
-
|
|
90
|
+
|
|
88
91
|
return (
|
|
89
92
|
<div className={classes.root} data-cy="CartPage-root">
|
|
90
93
|
<StoreTitle>
|
|
@@ -110,14 +113,14 @@ const CartPage = props => {
|
|
|
110
113
|
</div>
|
|
111
114
|
<div className={classes.body}>
|
|
112
115
|
<div className={classes.items_container}>{productListing}</div>
|
|
113
|
-
<div className={classes.price_adjustments_container}>
|
|
116
|
+
{/* <div className={classes.price_adjustments_container}>
|
|
114
117
|
{priceAdjustments}
|
|
115
|
-
</div>
|
|
116
|
-
<div className={classes.summary_container}>
|
|
118
|
+
</div> */}
|
|
119
|
+
{/* <div className={classes.summary_container}>
|
|
117
120
|
<div className={classes.summary_contents}>
|
|
118
121
|
{priceSummary}
|
|
119
122
|
</div>
|
|
120
|
-
</div>
|
|
123
|
+
</div> */}
|
|
121
124
|
</div>
|
|
122
125
|
</div>
|
|
123
126
|
);
|