@riosst100/pwa-marketplace 3.0.0 → 3.0.3
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 +1 -1
- package/i18n/id_ID.json +1 -1
- package/package.json +1 -1
- package/src/componentOverrideMapping.js +2 -0
- package/src/components/CheckoutHeader/checkoutHeader.js +162 -0
- package/src/components/CheckoutHeader/checkoutHeader.module.css +171 -0
- package/src/components/CheckoutHeader/index.js +1 -0
- package/src/components/FavoriteSeller/AddToListButton/addToListButton.module.css +2 -2
- package/src/components/FilterTop/FilterBlockList/filterTopItem.module.css +2 -0
- package/src/components/OrderDetail/components/itemsOrdered.js +6 -1
- package/src/components/RMAPage/components/productItem.css +15 -0
- package/src/components/RMAPage/components/productItem.js +43 -13
- package/src/components/RMAPage/components/productItem.module.css +15 -0
- package/src/components/SellerCoupon/index.js +1 -0
- package/src/components/SellerCoupon/sellerCoupon.js +84 -0
- package/src/components/SellerCoupon/sellerCoupon.module.css +110 -0
- package/src/components/SellerCoupon/sellerCouponCheckout.js +147 -0
- package/src/components/SellerCoupon/sellerCouponCheckout.module.css +85 -0
- package/src/components/SellerDetail/sellerDetail.js +10 -2
- package/src/components/SellerProducts/sellerProducts.js +4 -2
- package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary.js +10 -1
- package/src/overwrites/peregrine/lib/talons/CartPage/useCartPage.js +121 -0
- package/src/overwrites/peregrine/lib/talons/CheckoutPage/checkoutPage.extended.gql.js +17 -1
- package/src/overwrites/peregrine/lib/talons/Header/useCartTrigger.js +82 -0
- package/src/overwrites/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js +17 -1
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +11 -11
- package/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.js +24 -6
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +6 -2
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/productListingBySeller.js +3 -1
- package/src/overwrites/venia-ui/lib/components/CartPage/cartPage.js +20 -4
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/OrderSummary/orderSummary.js +1 -1
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.js +1 -1
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentMethods.js +1 -1
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/PriceAdjustments/priceAdjustments.js +74 -6
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.js +3 -3
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/checkoutPage.js +53 -2
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/checkoutPage.module.css +1 -1
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadio.js +1 -2
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js +10 -27
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/subFilterItemRadioGroup.js +1 -1
- package/src/overwrites/venia-ui/lib/components/Footer/footer.js +14 -4
- package/src/overwrites/venia-ui/lib/components/Footer/footer.module.css +16 -4
- package/src/overwrites/venia-ui/lib/components/Gallery/item.js +9 -8
- package/src/overwrites/venia-ui/lib/components/Header/accountTrigger.js +3 -3
- package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.js +9 -6
- package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.module.css +1 -1
- package/src/overwrites/venia-ui/lib/components/Header/header.js +2 -0
- package/src/overwrites/venia-ui/lib/components/Header/wishlistTrigger.js +4 -4
- package/src/overwrites/venia-ui/lib/components/Main/main.js +9 -4
- package/src/overwrites/venia-ui/lib/components/Main/main.module.css +2 -2
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +100 -72
- package/src/overwrites/venia-ui/lib/components/ToastContainer/toast.module.css +3 -3
- package/src/talons/Header/useCartTrigger.js +82 -0
- package/src/talons/Seller/seller.gql.js +42 -1
- package/src/talons/Seller/useSeller.js +25 -2
|
@@ -5,6 +5,8 @@ import { useMutation, useQuery } from '@apollo/client';
|
|
|
5
5
|
import { useCartContext } from '@magento/peregrine/lib/context/cart';
|
|
6
6
|
import { useUserContext } from '@magento/peregrine/lib/context/user';
|
|
7
7
|
|
|
8
|
+
import { useHistory } from 'react-router-dom';
|
|
9
|
+
|
|
8
10
|
import { appendOptionsToPayload } from '@magento/peregrine/lib/util/appendOptionsToPayload';
|
|
9
11
|
import { findMatchingVariant } from '@magento/peregrine/lib/util/findMatchingProductVariant';
|
|
10
12
|
import { isProductConfigurable } from '@magento/peregrine/lib/util/isProductConfigurable';
|
|
@@ -336,6 +338,16 @@ export const useProductFullDetail = props => {
|
|
|
336
338
|
isPreview
|
|
337
339
|
} = props;
|
|
338
340
|
|
|
341
|
+
const history = useHistory();
|
|
342
|
+
|
|
343
|
+
const handleToastAction = useCallback(
|
|
344
|
+
(removeToast) => {
|
|
345
|
+
history.push('/cart');
|
|
346
|
+
removeToast();
|
|
347
|
+
},
|
|
348
|
+
[history]
|
|
349
|
+
);
|
|
350
|
+
|
|
339
351
|
const [, { addToast }] = useToasts();
|
|
340
352
|
|
|
341
353
|
const { data: productReviewData, loading: loadingProductReview, error: errorProductReview, refetch: refetchProductReviews } = useQuery(
|
|
@@ -779,6 +791,9 @@ export const useProductFullDetail = props => {
|
|
|
779
791
|
}, [currentUser]);
|
|
780
792
|
|
|
781
793
|
return {
|
|
794
|
+
addToCartResponseData,
|
|
795
|
+
errorAddingProductToCart,
|
|
796
|
+
isAddProductLoading,
|
|
782
797
|
breadcrumbCategoryId,
|
|
783
798
|
errorMessage: derivedErrorMessage,
|
|
784
799
|
handleAddToCart,
|
|
@@ -813,6 +828,7 @@ export const useProductFullDetail = props => {
|
|
|
813
828
|
handleSubmitReview,
|
|
814
829
|
loadingCreateReview,
|
|
815
830
|
errorCreateReview,
|
|
816
|
-
defaultNickname
|
|
831
|
+
defaultNickname,
|
|
832
|
+
handleToastAction
|
|
817
833
|
};
|
|
818
834
|
};
|
|
@@ -106,7 +106,7 @@ const Breadcrumbs = props => {
|
|
|
106
106
|
currentFilter && currentFilter.length && currentFilter.map((filter, index) => {
|
|
107
107
|
currentProduct ? (
|
|
108
108
|
filterBreadcrumbsElement.push(
|
|
109
|
-
<
|
|
109
|
+
<Fragment key={index}>
|
|
110
110
|
<span className={classes.divider}>{DELIMITER}</span>
|
|
111
111
|
<Link
|
|
112
112
|
className={classes.link}
|
|
@@ -115,12 +115,12 @@ const Breadcrumbs = props => {
|
|
|
115
115
|
>
|
|
116
116
|
{filter.label}
|
|
117
117
|
</Link>
|
|
118
|
-
</
|
|
118
|
+
</Fragment>
|
|
119
119
|
)
|
|
120
120
|
) : (
|
|
121
121
|
customPage ? (
|
|
122
122
|
filterBreadcrumbsElement.push(
|
|
123
|
-
<
|
|
123
|
+
<Fragment key={index}>
|
|
124
124
|
<span className={classes.divider}>{DELIMITER}</span>
|
|
125
125
|
<Link
|
|
126
126
|
className={classes.link}
|
|
@@ -129,14 +129,14 @@ const Breadcrumbs = props => {
|
|
|
129
129
|
>
|
|
130
130
|
{filter.label}
|
|
131
131
|
</Link>
|
|
132
|
-
</
|
|
132
|
+
</Fragment>
|
|
133
133
|
)
|
|
134
134
|
) : filterBreadcrumbsElement.push(
|
|
135
135
|
index == lastIndex ?
|
|
136
|
-
<
|
|
136
|
+
<Fragment key={index}>
|
|
137
137
|
<span className={classes.divider}>{DELIMITER}</span>
|
|
138
138
|
<span className={cn(classes.currentCategory, 'text-blue-700 font-medium')}>{filter.label}</span>
|
|
139
|
-
</
|
|
139
|
+
</Fragment> : <Fragment key={index}>
|
|
140
140
|
<span className={classes.divider}>{DELIMITER}</span>
|
|
141
141
|
<Link
|
|
142
142
|
className={classes.link}
|
|
@@ -145,13 +145,13 @@ const Breadcrumbs = props => {
|
|
|
145
145
|
>
|
|
146
146
|
{filter.label}
|
|
147
147
|
</Link>
|
|
148
|
-
</
|
|
148
|
+
</Fragment>
|
|
149
149
|
)
|
|
150
150
|
);
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
const currentCategoryLink = currentCategory == "dCollectible Card Games" ? '' : (customPage || currentProduct || currentFilter && currentFilter.length ? (
|
|
154
|
-
|
|
154
|
+
<Fragment>
|
|
155
155
|
<span className={classes.divider}>{DELIMITER}</span>
|
|
156
156
|
<Link
|
|
157
157
|
className={classes.link}
|
|
@@ -160,12 +160,12 @@ const Breadcrumbs = props => {
|
|
|
160
160
|
>
|
|
161
161
|
{currentCategory}
|
|
162
162
|
</Link>
|
|
163
|
-
|
|
163
|
+
</Fragment>
|
|
164
164
|
) : (
|
|
165
|
-
|
|
165
|
+
<Fragment>
|
|
166
166
|
<span className={classes.divider}>{DELIMITER}</span>
|
|
167
167
|
<span className={cn(classes.currentCategory, 'text-blue-700 font-medium')}>{currentCategory}</span>
|
|
168
|
-
|
|
168
|
+
</Fragment>
|
|
169
169
|
));
|
|
170
170
|
|
|
171
171
|
const currentProductNode = currentProduct ? (
|
|
@@ -28,9 +28,9 @@ import cn from 'classnames';
|
|
|
28
28
|
* import PriceSummary from "@magento/venia-ui/lib/components/CartPage/PriceSummary";
|
|
29
29
|
*/
|
|
30
30
|
const PriceSummary = props => {
|
|
31
|
-
const { isUpdating, sellerUrl } = props;
|
|
31
|
+
const { isUpdating, sellerUrl, setIsProceedToCheckout, isProceedToCheckout } = props;
|
|
32
32
|
const classes = useStyle(defaultClasses, props.classes);
|
|
33
|
-
const talonProps = usePriceSummary();
|
|
33
|
+
const talonProps = usePriceSummary({ setIsProceedToCheckout });
|
|
34
34
|
|
|
35
35
|
const {
|
|
36
36
|
handleProceedToCheckout,
|
|
@@ -39,7 +39,8 @@ const PriceSummary = props => {
|
|
|
39
39
|
hasItems,
|
|
40
40
|
isCheckout,
|
|
41
41
|
isLoading,
|
|
42
|
-
flatData
|
|
42
|
+
flatData,
|
|
43
|
+
initCheckoutSplitCartLoading
|
|
43
44
|
} = talonProps;
|
|
44
45
|
const { formatMessage } = useIntl();
|
|
45
46
|
|
|
@@ -87,7 +88,7 @@ const PriceSummary = props => {
|
|
|
87
88
|
defaultMessage: 'Estimated Total'
|
|
88
89
|
});
|
|
89
90
|
|
|
90
|
-
const proceedToCheckoutButton =
|
|
91
|
+
const proceedToCheckoutButton = (
|
|
91
92
|
<div className={cn(classes.checkoutButton_container, 'block !mt-6 !min-h-auto')}>
|
|
92
93
|
<Button
|
|
93
94
|
disabled={isPriceUpdating}
|
|
@@ -106,7 +107,24 @@ const PriceSummary = props => {
|
|
|
106
107
|
/>
|
|
107
108
|
</Button>
|
|
108
109
|
</div>
|
|
109
|
-
)
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const loadingCheckoutButton = (
|
|
113
|
+
<div className={cn(classes.checkoutButton_container, 'block !mt-6 !min-h-auto')}>
|
|
114
|
+
<Button
|
|
115
|
+
disabled={true}
|
|
116
|
+
priority={'high'}
|
|
117
|
+
onKeyDown={handleEnterKeyPress}
|
|
118
|
+
data-cy="PriceSummary-checkoutButton"
|
|
119
|
+
classes={{
|
|
120
|
+
rootClass: 'w-full',
|
|
121
|
+
content: 'font-medium text-[16px] capitalize',
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
Loading Checkout...
|
|
125
|
+
</Button>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
110
128
|
|
|
111
129
|
return (
|
|
112
130
|
<div className={cn(classes.root, 'pb-6 px-3')} data-cy="PriceSummary-root">
|
|
@@ -207,7 +225,7 @@ const PriceSummary = props => {
|
|
|
207
225
|
</ul>
|
|
208
226
|
</div>
|
|
209
227
|
)}
|
|
210
|
-
{proceedToCheckoutButton}
|
|
228
|
+
{isProceedToCheckout ? loadingCheckoutButton : proceedToCheckoutButton}
|
|
211
229
|
</div>
|
|
212
230
|
);
|
|
213
231
|
};
|
|
@@ -31,6 +31,8 @@ const ProductListing = props => {
|
|
|
31
31
|
setIsCartUpdating,
|
|
32
32
|
fetchCartDetails,
|
|
33
33
|
isCartUpdating,
|
|
34
|
+
setIsProceedToCheckout,
|
|
35
|
+
isProceedToCheckout,
|
|
34
36
|
hasItems
|
|
35
37
|
} = props;
|
|
36
38
|
|
|
@@ -50,10 +52,10 @@ const ProductListing = props => {
|
|
|
50
52
|
if (isLoading) {
|
|
51
53
|
return (
|
|
52
54
|
<LoadingIndicator>
|
|
53
|
-
<FormattedMessage
|
|
55
|
+
{/* <FormattedMessage
|
|
54
56
|
id={'productListing.loading'}
|
|
55
57
|
defaultMessage={'Fetching Cart...'}
|
|
56
|
-
/>
|
|
58
|
+
/> */}
|
|
57
59
|
</LoadingIndicator>
|
|
58
60
|
);
|
|
59
61
|
}
|
|
@@ -91,8 +93,10 @@ const ProductListing = props => {
|
|
|
91
93
|
activeEditItem={activeEditItem}
|
|
92
94
|
isLoading={isLoading}
|
|
93
95
|
hasItems={hasItems}
|
|
96
|
+
setIsProceedToCheckout={setIsProceedToCheckout}
|
|
94
97
|
key={index}
|
|
95
98
|
error={error}
|
|
99
|
+
isProceedToCheckout={isProceedToCheckout}
|
|
96
100
|
setActiveEditItem={setActiveEditItem}
|
|
97
101
|
wishlistConfig={wishlistConfig}
|
|
98
102
|
setIsCartUpdating={setIsCartUpdating}
|
|
@@ -37,6 +37,8 @@ const ProductListingBySeller = props => {
|
|
|
37
37
|
setIsCartUpdating,
|
|
38
38
|
fetchCartDetails,
|
|
39
39
|
activeEditItem,
|
|
40
|
+
setIsProceedToCheckout,
|
|
41
|
+
isProceedToCheckout,
|
|
40
42
|
setActiveEditItem,
|
|
41
43
|
wishlistConfig,
|
|
42
44
|
isLoading,
|
|
@@ -80,7 +82,7 @@ const ProductListingBySeller = props => {
|
|
|
80
82
|
));
|
|
81
83
|
|
|
82
84
|
const priceSummary = hasItems ? (
|
|
83
|
-
<PriceSummary isUpdating={isCartUpdating} sellerUrl={seller.seller_url} />
|
|
85
|
+
<PriceSummary isProceedToCheckout={isProceedToCheckout} setIsProceedToCheckout={setIsProceedToCheckout} setIsCartUpdating={setIsCartUpdating} isUpdating={isCartUpdating} sellerUrl={seller.seller_url} />
|
|
84
86
|
) : null;
|
|
85
87
|
return (
|
|
86
88
|
<Fragment>
|
|
@@ -14,6 +14,7 @@ import PriceSummary from './PriceSummary';
|
|
|
14
14
|
import ProductListing from './ProductListing';
|
|
15
15
|
import defaultClasses from './cartPage.module.css';
|
|
16
16
|
import cn from 'classnames';
|
|
17
|
+
import { useHistory } from 'react-router-dom';
|
|
17
18
|
|
|
18
19
|
const CheckIcon = <Icon size={20} src={Check} />;
|
|
19
20
|
|
|
@@ -45,19 +46,31 @@ const CartPage = props => {
|
|
|
45
46
|
onAddToWishlistSuccess,
|
|
46
47
|
setIsCartUpdating,
|
|
47
48
|
shouldShowLoadingIndicator,
|
|
48
|
-
|
|
49
|
+
isProceedToCheckout,
|
|
50
|
+
setIsProceedToCheckout,
|
|
51
|
+
wishlistSuccessProps,
|
|
52
|
+
isGuestCheckout
|
|
49
53
|
} = talonProps;
|
|
50
|
-
|
|
54
|
+
|
|
51
55
|
const classes = useStyle(defaultClasses, props.classes);
|
|
52
56
|
const { formatMessage } = useIntl();
|
|
53
57
|
const [, { addToast }] = useToasts();
|
|
54
58
|
|
|
59
|
+
const history = useHistory();
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (isGuestCheckout) {
|
|
63
|
+
history.push('/sign-in');
|
|
64
|
+
}
|
|
65
|
+
}, [isGuestCheckout, history]);
|
|
66
|
+
|
|
55
67
|
useEffect(() => {
|
|
56
68
|
if (wishlistSuccessProps) {
|
|
57
69
|
addToast({ ...wishlistSuccessProps, icon: CheckIcon });
|
|
58
70
|
}
|
|
59
71
|
}, [addToast, wishlistSuccessProps]);
|
|
60
72
|
|
|
73
|
+
|
|
61
74
|
if (shouldShowLoadingIndicator) {
|
|
62
75
|
return fullPageLoadingIndicator;
|
|
63
76
|
}
|
|
@@ -70,7 +83,9 @@ const CartPage = props => {
|
|
|
70
83
|
<ProductListing
|
|
71
84
|
onAddToWishlistSuccess={onAddToWishlistSuccess}
|
|
72
85
|
setIsCartUpdating={setIsCartUpdating}
|
|
86
|
+
isProceedToCheckout={isProceedToCheckout}
|
|
73
87
|
fetchCartDetails={fetchCartDetails}
|
|
88
|
+
setIsProceedToCheckout={setIsProceedToCheckout}
|
|
74
89
|
isCartUpdating={isCartUpdating}
|
|
75
90
|
hasItems={hasItems}
|
|
76
91
|
/>
|
|
@@ -93,7 +108,7 @@ const CartPage = props => {
|
|
|
93
108
|
<StoreTitle>
|
|
94
109
|
{formatMessage({
|
|
95
110
|
id: 'cartPage.title',
|
|
96
|
-
defaultMessage: 'Cart'
|
|
111
|
+
defaultMessage: 'Shopping Cart'
|
|
97
112
|
})}
|
|
98
113
|
</StoreTitle>
|
|
99
114
|
<div className={cn(classes.heading_container, 'mb-[30px]')}>
|
|
@@ -104,7 +119,7 @@ const CartPage = props => {
|
|
|
104
119
|
>
|
|
105
120
|
<FormattedMessage
|
|
106
121
|
id={'cartPage.heading'}
|
|
107
|
-
defaultMessage={'Cart'}
|
|
122
|
+
defaultMessage={'Shopping Cart'}
|
|
108
123
|
/>
|
|
109
124
|
</h1>
|
|
110
125
|
<div className={classes.stockStatusMessageContainer}>
|
|
@@ -127,3 +142,4 @@ const CartPage = props => {
|
|
|
127
142
|
};
|
|
128
143
|
|
|
129
144
|
export default CartPage;
|
|
145
|
+
|
|
@@ -12,7 +12,7 @@ const OrderSummary = props => {
|
|
|
12
12
|
<h2 aria-live="polite" className="text-[16px] font-medium mb-4">
|
|
13
13
|
<FormattedMessage
|
|
14
14
|
id={'checkoutPage.orderSummary'}
|
|
15
|
-
defaultMessage={'Summary'}
|
|
15
|
+
defaultMessage={'Order Summary'}
|
|
16
16
|
/>
|
|
17
17
|
</h2>
|
|
18
18
|
<PriceSummary isUpdating={props.isUpdating} />
|
package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.js
CHANGED
|
@@ -49,7 +49,7 @@ const PaymentInformation = props => {
|
|
|
49
49
|
<LoadingIndicator classes={{ root: classes.loading }}>
|
|
50
50
|
<FormattedMessage
|
|
51
51
|
id={'checkoutPage.loadingPaymentInformation'}
|
|
52
|
-
defaultMessage={'Fetching Payment
|
|
52
|
+
defaultMessage={'Fetching Payment Method'}
|
|
53
53
|
/>
|
|
54
54
|
</LoadingIndicator>
|
|
55
55
|
);
|
package/src/overwrites/venia-ui/lib/components/CheckoutPage/PriceAdjustments/priceAdjustments.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import React, { Suspense } from 'react';
|
|
1
|
+
import React, { Suspense, useCallback, useState } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { func } from 'prop-types';
|
|
4
|
+
import { useMutation, useQuery } from '@apollo/client';
|
|
5
|
+
import { useCartContext } from '@magento/peregrine/lib/context/cart';
|
|
4
6
|
|
|
5
7
|
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
8
|
import LoadingIndicator from '@magento/venia-ui/lib/components/LoadingIndicator';
|
|
7
9
|
import { Accordion, Section } from '@magento/venia-ui/lib/components/Accordion';
|
|
8
|
-
import
|
|
10
|
+
import SellerCouponCheckout from '@riosst100/pwa-marketplace/src/components/SellerCoupon/sellerCouponCheckout';
|
|
11
|
+
import couponCodeOperations from '@magento/peregrine/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCode.gql';
|
|
9
12
|
import GiftCardSection from '@magento/venia-ui/lib/components/CartPage/PriceAdjustments/giftCardSection';
|
|
10
13
|
import GiftOptionsSection from '@magento/venia-ui/lib/components/CartPage/PriceAdjustments/giftOptionsSection';
|
|
11
14
|
|
|
@@ -20,8 +23,44 @@ import cn from 'classnames';
|
|
|
20
23
|
const PriceAdjustments = props => {
|
|
21
24
|
const classes = useStyle(defaultClasses, props.classes);
|
|
22
25
|
|
|
23
|
-
const { setPageIsUpdating } = props;
|
|
26
|
+
const { setPageIsUpdating, couponData, couponLoading, couponError } = props;
|
|
24
27
|
const { formatMessage } = useIntl();
|
|
28
|
+
const [{ cartId }] = useCartContext();
|
|
29
|
+
const [applyCoupon, { loading: applyingCoupon }] = useMutation(couponCodeOperations.applyCouponMutation);
|
|
30
|
+
const [removeCoupon, { loading: removingCoupon }] = useMutation(couponCodeOperations.removeCouponMutation);
|
|
31
|
+
const { data: appliedData, loading: appliedLoading } = useQuery(
|
|
32
|
+
couponCodeOperations.getAppliedCouponsQuery,
|
|
33
|
+
{ variables: { cartId }, skip: !cartId }
|
|
34
|
+
);
|
|
35
|
+
const [sectionOpen, setSectionOpen] = useState(false);
|
|
36
|
+
|
|
37
|
+
const handleApplyFromClaim = useCallback(async (item) => {
|
|
38
|
+
if (!item?.code || !cartId) return;
|
|
39
|
+
try {
|
|
40
|
+
setPageIsUpdating(true);
|
|
41
|
+
await applyCoupon({
|
|
42
|
+
variables: { cartId, couponCode: item.code }
|
|
43
|
+
});
|
|
44
|
+
} catch (e) {
|
|
45
|
+
// silent; error surfaced by apollo links/toasts if configured
|
|
46
|
+
} finally {
|
|
47
|
+
setPageIsUpdating(false);
|
|
48
|
+
}
|
|
49
|
+
}, [applyCoupon, cartId, setPageIsUpdating]);
|
|
50
|
+
|
|
51
|
+
const handleRemoveCoupon = useCallback(async () => {
|
|
52
|
+
if (!cartId) return;
|
|
53
|
+
try {
|
|
54
|
+
setPageIsUpdating(true);
|
|
55
|
+
await removeCoupon({ variables: { cartId } });
|
|
56
|
+
} catch (e) {
|
|
57
|
+
// silent
|
|
58
|
+
} finally {
|
|
59
|
+
setPageIsUpdating(false);
|
|
60
|
+
}
|
|
61
|
+
}, [removeCoupon, cartId, setPageIsUpdating]);
|
|
62
|
+
|
|
63
|
+
const appliedCoupons = appliedData?.cart?.applied_coupons || [];
|
|
25
64
|
|
|
26
65
|
return (
|
|
27
66
|
<div className={classes.root}>
|
|
@@ -36,17 +75,46 @@ const PriceAdjustments = props => {
|
|
|
36
75
|
id={'coupon_code'}
|
|
37
76
|
title={formatMessage({
|
|
38
77
|
id: 'checkoutPage.couponCode',
|
|
39
|
-
defaultMessage: '
|
|
78
|
+
defaultMessage: 'Apply Coupon Code'
|
|
40
79
|
})}
|
|
41
80
|
classes={{
|
|
42
81
|
root: cn('border border-gray-100 rounded-md max-w-[400px] p-2.5'),
|
|
43
|
-
title: 'text-[16px] font-medium',
|
|
82
|
+
title: 'text-[16px] font-medium cursor-pointer',
|
|
44
83
|
title_wrapper: 'gap-sm grid grid-cols-1 grid-flow-col h-[38px] items-center justify-items-start',
|
|
45
84
|
contents_container: 'p-0'
|
|
46
85
|
}}
|
|
86
|
+
onClick={() => setSectionOpen(prev => !prev)}
|
|
47
87
|
>
|
|
48
88
|
<Suspense fallback={<LoadingIndicator />}>
|
|
49
|
-
|
|
89
|
+
{sectionOpen && (
|
|
90
|
+
<SellerCouponCheckout
|
|
91
|
+
couponData={couponData}
|
|
92
|
+
couponLoading={couponLoading || applyingCoupon || appliedLoading || removingCoupon}
|
|
93
|
+
couponError={couponError}
|
|
94
|
+
autoOpen={true}
|
|
95
|
+
closeOnClaim={true}
|
|
96
|
+
onSelectCoupon={handleApplyFromClaim}
|
|
97
|
+
onTriggerRender={() => null}
|
|
98
|
+
/>
|
|
99
|
+
)}
|
|
100
|
+
{appliedCoupons.length > 0 && (
|
|
101
|
+
<div className="mt-3 flex items-center gap-2 flex-wrap">
|
|
102
|
+
{appliedCoupons.map(c => (
|
|
103
|
+
<div key={c.code} className="flex items-center gap-2 bg-[#fff8f1] border border-[#ffb891] rounded px-2 py-1 text-sm font-medium text-[#f76b1c]">
|
|
104
|
+
<span>{c.code}</span>
|
|
105
|
+
<button
|
|
106
|
+
type="button"
|
|
107
|
+
onClick={handleRemoveCoupon}
|
|
108
|
+
disabled={removingCoupon}
|
|
109
|
+
className="text-[#a94442] hover:text-[#f26313] disabled:opacity-50"
|
|
110
|
+
aria-label={formatMessage({ id: 'checkoutPage.removeCoupon', defaultMessage: 'Remove coupon' })}
|
|
111
|
+
>
|
|
112
|
+
×
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
115
|
+
))}
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
50
118
|
</Suspense>
|
|
51
119
|
</Section>
|
|
52
120
|
<GiftCardSection setIsCartUpdating={setPageIsUpdating} />
|
|
@@ -50,7 +50,7 @@ const ShippingInformation = props => {
|
|
|
50
50
|
<LoadingIndicator classes={{ root: classes.loading }}>
|
|
51
51
|
<FormattedMessage
|
|
52
52
|
id={'shippingInformation.loading'}
|
|
53
|
-
defaultMessage={'Fetching Shipping
|
|
53
|
+
defaultMessage={'Fetching Shipping Address...'}
|
|
54
54
|
/>
|
|
55
55
|
</LoadingIndicator>
|
|
56
56
|
);
|
|
@@ -68,7 +68,7 @@ const ShippingInformation = props => {
|
|
|
68
68
|
<h5 className={classes.cardTitle}>
|
|
69
69
|
<FormattedMessage
|
|
70
70
|
id={'shippingInformation.cardTitle'}
|
|
71
|
-
defaultMessage={'Shipping
|
|
71
|
+
defaultMessage={'Shipping Address'}
|
|
72
72
|
/>
|
|
73
73
|
</h5>
|
|
74
74
|
<LinkButton
|
|
@@ -100,7 +100,7 @@ const ShippingInformation = props => {
|
|
|
100
100
|
>
|
|
101
101
|
<FormattedMessage
|
|
102
102
|
id={'shippingInformation.editTitle'}
|
|
103
|
-
defaultMessage={'Shipping
|
|
103
|
+
defaultMessage={'Shipping Address'}
|
|
104
104
|
/>
|
|
105
105
|
</h3>
|
|
106
106
|
<div className={classes.editWrapper}>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { Fragment, useEffect } from 'react';
|
|
1
|
+
import React, { Fragment, useEffect, useMemo } from 'react';
|
|
2
|
+
import { useQuery } from '@apollo/client';
|
|
2
3
|
import { shape, string } from 'prop-types';
|
|
3
4
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
4
5
|
import { AlertCircle as AlertCircleIcon } from 'react-feather';
|
|
@@ -28,9 +29,11 @@ import ShippingInformation from './ShippingInformation';
|
|
|
28
29
|
import OrderConfirmationPage from './OrderConfirmationPage';
|
|
29
30
|
import ItemsReview from './ItemsReview';
|
|
30
31
|
import GoogleReCaptcha from '@magento/venia-ui/lib/components/GoogleReCaptcha';
|
|
32
|
+
import { GET_COUPON_CODE_QUERY } from '@riosst100/pwa-marketplace/src/talons/Seller/seller.gql';
|
|
31
33
|
|
|
32
34
|
import defaultClasses from './checkoutPage.module.css';
|
|
33
35
|
import ScrollAnchor from '@magento/venia-ui/lib/components/ScrollAnchor/scrollAnchor';
|
|
36
|
+
import { useHistory } from 'react-router-dom';
|
|
34
37
|
|
|
35
38
|
const errorIcon = <Icon src={AlertCircleIcon} size={20} />;
|
|
36
39
|
|
|
@@ -84,6 +87,21 @@ const CheckoutPage = props => {
|
|
|
84
87
|
|
|
85
88
|
const [, { addToast }] = useToasts();
|
|
86
89
|
|
|
90
|
+
const history = useHistory();
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (isGuestCheckout) {
|
|
95
|
+
history.push('/sign-in');
|
|
96
|
+
}
|
|
97
|
+
}, [isGuestCheckout, history]);
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (!isLoading && !isUpdating && !cartItems.length && isCartEmpty) {
|
|
101
|
+
history.push('/cart');
|
|
102
|
+
}
|
|
103
|
+
}, [isCartEmpty, isLoading, isUpdating, cartItems, history]);
|
|
104
|
+
|
|
87
105
|
useEffect(() => {
|
|
88
106
|
if (hasError) {
|
|
89
107
|
const message =
|
|
@@ -115,6 +133,34 @@ const CheckoutPage = props => {
|
|
|
115
133
|
|
|
116
134
|
let checkoutContent;
|
|
117
135
|
|
|
136
|
+
const sellerUrls = useMemo(() => {
|
|
137
|
+
if (!cartItems || !cartItems.length) return [];
|
|
138
|
+
const urls = cartItems
|
|
139
|
+
.map(item => item?.seller?.seller_url)
|
|
140
|
+
.filter(Boolean);
|
|
141
|
+
return Array.from(new Set(urls));
|
|
142
|
+
}, [cartItems]);
|
|
143
|
+
|
|
144
|
+
const sellerUrl = sellerUrls[0] || null;
|
|
145
|
+
|
|
146
|
+
const {
|
|
147
|
+
data: couponData,
|
|
148
|
+
loading: couponLoading,
|
|
149
|
+
error: couponError
|
|
150
|
+
} = useQuery(GET_COUPON_CODE_QUERY, {
|
|
151
|
+
variables: {
|
|
152
|
+
sellerUrl,
|
|
153
|
+
pageSize: 20,
|
|
154
|
+
currentPage: 1,
|
|
155
|
+
filters: {
|
|
156
|
+
is_public: { eq: '1' }
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
skip: !sellerUrl,
|
|
160
|
+
fetchPolicy: 'cache-and-network',
|
|
161
|
+
nextFetchPolicy: 'cache-first'
|
|
162
|
+
});
|
|
163
|
+
|
|
118
164
|
const heading = isGuestCheckout
|
|
119
165
|
? formatMessage({
|
|
120
166
|
id: 'checkoutPage.guestCheckout',
|
|
@@ -240,7 +286,12 @@ const CheckoutPage = props => {
|
|
|
240
286
|
const priceAdjustmentsSection =
|
|
241
287
|
checkoutStep === CHECKOUT_STEP.PAYMENT ? (
|
|
242
288
|
<div className={classes.price_adjustments_container}>
|
|
243
|
-
<PriceAdjustments
|
|
289
|
+
<PriceAdjustments
|
|
290
|
+
setPageIsUpdating={setIsUpdating}
|
|
291
|
+
couponData={couponData}
|
|
292
|
+
couponLoading={couponLoading}
|
|
293
|
+
couponError={couponError}
|
|
294
|
+
/>
|
|
244
295
|
</div>
|
|
245
296
|
) : null;
|
|
246
297
|
|
|
@@ -44,7 +44,6 @@ const FilterItemRadio = props => {
|
|
|
44
44
|
classes={classes}
|
|
45
45
|
id={`item-${group}-${value}`}
|
|
46
46
|
label={title}
|
|
47
|
-
isSubFilter={isSubFilter}
|
|
48
47
|
value={value}
|
|
49
48
|
onChange={handleOnchange}
|
|
50
49
|
data-cy="FilterDefault-radio"
|
|
@@ -74,7 +73,7 @@ FilterItemRadio.propTypes = {
|
|
|
74
73
|
path: string
|
|
75
74
|
}).isRequired,
|
|
76
75
|
onApply: func,
|
|
77
|
-
labels: instanceOf(
|
|
76
|
+
labels: instanceOf(WeakMap).isRequired
|
|
78
77
|
};
|
|
79
78
|
|
|
80
79
|
export default FilterItemRadio;
|
package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js
CHANGED
|
@@ -45,32 +45,15 @@ const FilterItemRadioGroup = props => {
|
|
|
45
45
|
// }
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/>
|
|
58
|
-
{/* {subFilter && <FilterBlock
|
|
59
|
-
key={subFilter.key}
|
|
60
|
-
filterApi={subFilter.filterApi}
|
|
61
|
-
filterState={subFilter.filterState}
|
|
62
|
-
filterFrontendInput={subFilter.filterFrontendInput}
|
|
63
|
-
group={subFilter.group}
|
|
64
|
-
allowedSubFilters={newAllowedSubFilters}
|
|
65
|
-
subFilterItems={subFilterItems}
|
|
66
|
-
isSubFilter={true}
|
|
67
|
-
items={subFilter.items}
|
|
68
|
-
name={''}
|
|
69
|
-
onApply={subFilter.onApply}
|
|
70
|
-
initialOpen={true}
|
|
71
|
-
/>} */}
|
|
72
|
-
{/* {subFilterBlock} */}
|
|
73
|
-
</>
|
|
48
|
+
<FilterItemRadio
|
|
49
|
+
key={index}
|
|
50
|
+
filterApi={filterApi}
|
|
51
|
+
filterState={filterState}
|
|
52
|
+
group={group}
|
|
53
|
+
item={item}
|
|
54
|
+
onApply={onApply}
|
|
55
|
+
labels={labels}
|
|
56
|
+
/>
|
|
74
57
|
);
|
|
75
58
|
});
|
|
76
59
|
}, [filterApi, allowedSubFilters, subFilter, filterState, group, items, labels, onApply,isListExpanded,itemCountToShow]);
|
|
@@ -122,7 +105,7 @@ FilterItemRadioGroup.propTypes = {
|
|
|
122
105
|
})
|
|
123
106
|
).isRequired,
|
|
124
107
|
onApply: func,
|
|
125
|
-
labels: instanceOf(
|
|
108
|
+
labels: instanceOf(WeakMap).isRequired
|
|
126
109
|
};
|
|
127
110
|
|
|
128
111
|
export default FilterItemRadioGroup;
|