@sonic-equipment/ui 260.0.4 → 260.0.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.
|
@@ -52,7 +52,10 @@ function SignInPage({ returnUrl } = {}) {
|
|
|
52
52
|
setIsSuccess(true);
|
|
53
53
|
navigate(returnUrl || paths.HOME, { reload: true });
|
|
54
54
|
};
|
|
55
|
-
const
|
|
55
|
+
const decodedReturnUrl = returnUrl
|
|
56
|
+
? decodeURIComponent(returnUrl).toLowerCase()
|
|
57
|
+
: undefined;
|
|
58
|
+
const allowGuestSignIn = !!decodedReturnUrl?.includes(paths.CHECKOUT_SHIPPING.toLowerCase());
|
|
56
59
|
const createAccountPath = `${paths.ACCOUNT_CREATE}${returnUrl ? `?returnUrl=${encodeURIComponent(returnUrl)}` : ''}`;
|
|
57
60
|
const onSignIn = ({ data }) => {
|
|
58
61
|
resetSignIn();
|
|
@@ -11,8 +11,6 @@ import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-pag
|
|
|
11
11
|
import { Page } from '../../components/page/page.js';
|
|
12
12
|
import { ErrorPage } from '../../error-page/error-page.js';
|
|
13
13
|
import { LoadingPage } from '../../loading-page/loading-page.js';
|
|
14
|
-
import { useSaveCartForLater } from '../../../shared/api/bff/hooks/cart/use-save-cart-for-later.js';
|
|
15
|
-
import { useIsAuthenticated } from '../../../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
|
|
16
14
|
import { useDeleteCartLineById } from '../../../shared/api/storefront/hooks/cart/use-delete-cart-line-by-id.js';
|
|
17
15
|
import { useDeleteCurrentCart } from '../../../shared/api/storefront/hooks/cart/use-delete-current-cart.js';
|
|
18
16
|
import { useFetchCurrentCartLinesWithAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-lines-with-atp.js';
|
|
@@ -27,22 +25,22 @@ function CartContent({ cartLines }) {
|
|
|
27
25
|
const paths = usePaths();
|
|
28
26
|
const { addToast } = useToast();
|
|
29
27
|
const { data: currentCart } = useFetchCurrentCartWithAtp();
|
|
30
|
-
const saveCartForLater = useSaveCartForLater({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
28
|
+
// const saveCartForLater = useSaveCartForLater({
|
|
29
|
+
// onError: () => {
|
|
30
|
+
// addToast({
|
|
31
|
+
// body: <FormattedMessage id="Unable to save cart for later." />,
|
|
32
|
+
// isUserDismissable: false,
|
|
33
|
+
// messageType: 'danger',
|
|
34
|
+
// })
|
|
35
|
+
// },
|
|
36
|
+
// onSuccess: () => {
|
|
37
|
+
// addToast({
|
|
38
|
+
// body: <FormattedMessage id="Saved cart for later." />,
|
|
39
|
+
// isUserDismissable: false,
|
|
40
|
+
// messageType: 'success',
|
|
41
|
+
// })
|
|
42
|
+
// },
|
|
43
|
+
// })
|
|
46
44
|
const deleteCurrentCart = useDeleteCurrentCart({
|
|
47
45
|
onError: () => {
|
|
48
46
|
addToast({
|
|
@@ -75,7 +73,7 @@ function CartContent({ cartLines }) {
|
|
|
75
73
|
});
|
|
76
74
|
},
|
|
77
75
|
});
|
|
78
|
-
const isAuthenticated = useIsAuthenticated()
|
|
76
|
+
// const isAuthenticated = useIsAuthenticated()
|
|
79
77
|
if (!currentCart)
|
|
80
78
|
return null;
|
|
81
79
|
const currencyCode = getCurrencyCodeBySymbol(currentCart.currencySymbol);
|
|
@@ -83,9 +81,25 @@ function CartContent({ cartLines }) {
|
|
|
83
81
|
throw new Error(`Currency code not found for symbol ${currentCart.currencySymbol}`);
|
|
84
82
|
return (jsx(CheckoutPageLayout, { actions: {
|
|
85
83
|
primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutShippingCartTotalContinueButton", href: paths.CHECKOUT_SHIPPING, children: jsx(FormattedMessage, { id: "Start checkout" }) })),
|
|
86
|
-
secondary: isAuthenticated ? (
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
// secondary: isAuthenticated ? (
|
|
85
|
+
// <Button
|
|
86
|
+
// color="secondary"
|
|
87
|
+
// data-test-selector="saveCartForLaterButton"
|
|
88
|
+
// onClick={() => {
|
|
89
|
+
// saveCartForLater.mutate({ cart: currentCart })
|
|
90
|
+
// }}
|
|
91
|
+
// variant="outline">
|
|
92
|
+
// <FormattedMessage id="Save order" />
|
|
93
|
+
// </Button>
|
|
94
|
+
// ) : (
|
|
95
|
+
// <Button
|
|
96
|
+
// color="secondary"
|
|
97
|
+
// data-test-selector="saveCartForLaterButton"
|
|
98
|
+
// href={paths.SIGN_IN}
|
|
99
|
+
// variant="outline">
|
|
100
|
+
// <FormattedMessage id="Save order" />
|
|
101
|
+
// </Button>
|
|
102
|
+
// ),
|
|
89
103
|
}, mobileSummary: jsx(CartTotalsSummary, { currencyCode: currencyCode, totalAmount: currentCart.orderGrandTotal }), overview: jsx(CartTotals, { currencyCode: currencyCode, shippingCost: currentCart.shippingAndHandling, subtotal: currentCart.orderSubTotal, tax: currentCart.totalTax, total: currentCart.orderGrandTotal, vatPercentage: cartLines[0]?.pricing?.vatRate || 0 }), children: jsx(OrderLineList, { onRemoveAll: () => deleteCurrentCart.mutate(), children: cartLines.map(cartLine => (jsx(ConnectedOrderLineCard, { deliveryDate: cartLine.atp?.date ?? null, href: cartLine.productUri, image: {
|
|
90
104
|
fit: 'contain',
|
|
91
105
|
image: {
|
|
@@ -24,7 +24,7 @@ function ShippingPage() {
|
|
|
24
24
|
const { createEcommerceEvent, dataLayer } = useDataLayer();
|
|
25
25
|
const gaEventPushed = useRef(false);
|
|
26
26
|
const { data: cart, error: errorFetchCart, isLoading: isLoadingCart, refetch: refetchCart, } = useFetchCurrentCart();
|
|
27
|
-
const { data: session } = useFetchSession();
|
|
27
|
+
const { data: session, isLoading: isLoadingSession } = useFetchSession();
|
|
28
28
|
const hasNoBillToAddress = hasNo(cart?.billTo?.address1);
|
|
29
29
|
const isGuest = Boolean(session?.isGuest);
|
|
30
30
|
const { countries, currentCountry: selectedCountry, isFetching: isLoadingCountries, } = useCountries({
|
|
@@ -39,7 +39,10 @@ function ShippingPage() {
|
|
|
39
39
|
const { isLoading: isPatchingSession, mutate: patchSession } = usePatchSession();
|
|
40
40
|
const { error: errorPatchBillingAddress, isError, isLoading: isPatching, isSuccess, mutate: patchShippingDetails, } = usePatchShippingDetails();
|
|
41
41
|
const isAuthenticated = session?.isAuthenticated;
|
|
42
|
-
const isLoading = isLoadingCart ||
|
|
42
|
+
const isLoading = isLoadingCart ||
|
|
43
|
+
isLoadingCountries ||
|
|
44
|
+
isLoadingFulfillmentMethods ||
|
|
45
|
+
isLoadingSession;
|
|
43
46
|
const { isNavigating, navigate } = useNavigate();
|
|
44
47
|
const isPickup = Boolean(cart?.fulfillmentMethod.match(/pickup/i));
|
|
45
48
|
useEffect(() => {
|
|
@@ -48,7 +51,9 @@ function ShippingPage() {
|
|
|
48
51
|
return;
|
|
49
52
|
if (isAuthenticated === undefined)
|
|
50
53
|
return;
|
|
51
|
-
if (
|
|
54
|
+
if (isLoading)
|
|
55
|
+
return;
|
|
56
|
+
if (isAuthenticated === false)
|
|
52
57
|
return navigate(paths.CHECKOUT_SHIPPING_VIA_SIGNIN);
|
|
53
58
|
if (hasNo(cart))
|
|
54
59
|
return;
|
|
@@ -56,7 +61,7 @@ function ShippingPage() {
|
|
|
56
61
|
return navigate(paths.CART);
|
|
57
62
|
if (hasNo(cart.billTo))
|
|
58
63
|
return navigate(paths.CHECKOUT_SHIPPING_VIA_SIGNIN);
|
|
59
|
-
}, [cart, navigate, isAuthenticated, isNavigating, paths]);
|
|
64
|
+
}, [cart, navigate, isAuthenticated, isNavigating, paths, isLoading]);
|
|
60
65
|
useEffect(() => {
|
|
61
66
|
/* Guards for when the bill to address is saved and we should navigate to the next page */
|
|
62
67
|
if (isPatching)
|