diff --git a/libraries/commerce/cart/reducers/data.js b/libraries/commerce/cart/reducers/data.js index 1c1a9bc7bd..402c46d156 100644 --- a/libraries/commerce/cart/reducers/data.js +++ b/libraries/commerce/cart/reducers/data.js @@ -17,6 +17,7 @@ const defaultState = { productPendingCount: 0, flags: {}, activeFulfillmentSlot: null, + isFetching: false, }; /** diff --git a/themes/theme-ios11/components/AppBar/presets/DefaultBar/components/ProgressBar/index.jsx b/themes/theme-ios11/components/AppBar/presets/DefaultBar/components/ProgressBar/index.jsx index 01a47ae968..964f2bac3d 100644 --- a/themes/theme-ios11/components/AppBar/presets/DefaultBar/components/ProgressBar/index.jsx +++ b/themes/theme-ios11/components/AppBar/presets/DefaultBar/components/ProgressBar/index.jsx @@ -2,15 +2,24 @@ import React from 'react'; import { RouteContext } from '@shopgate/pwa-common/context'; import { LoadingContext } from '@shopgate/pwa-common/providers/'; import { ProgressBar } from '@shopgate/pwa-ui-shared'; +import { getCart } from '@shopgate/pwa-common-commerce/cart'; +import { useSelector } from 'react-redux'; -export default () => ( - - {({ visible, pathname }) => ( - - {({ isLoading }) => ( - - )} - - )} - -); +export default () => { + const { isFetching } = useSelector(getCart); + + return ( + + {({ visible, pathname }) => ( + + {({ isLoading }) => { + const isCartLoading = pathname === '/cart' && (isLoading('/cart') || isFetching); + return ( + + ); + }} + + )} + + ); +}; diff --git a/themes/theme-ios11/pages/Cart/components/Content/index.jsx b/themes/theme-ios11/pages/Cart/components/Content/index.jsx index 5a0b70b348..48060dcb35 100644 --- a/themes/theme-ios11/pages/Cart/components/Content/index.jsx +++ b/themes/theme-ios11/pages/Cart/components/Content/index.jsx @@ -1,6 +1,5 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; -import { LoadingContext } from '@shopgate/pwa-common/providers/'; import { getCartConfig, sortCartItems, @@ -12,13 +11,14 @@ import { FLAG_MULTI_LINE_RESERVE, CartItemGroup, CartItems, - CartItem, + CartItem, getCart, } from '@shopgate/engage/cart'; import { MessageBar, CardList, SurroundPortals } from '@shopgate/engage/components'; import { FulfillmentSheet } from '@shopgate/engage/locations'; import { BackBar } from 'Components/AppBar/presets'; import { getPageSettings } from '@shopgate/engage/core/config'; import { ProductListTypeProvider } from '@shopgate/engage/product'; +import { useSelector } from 'react-redux'; import CouponField from '../CouponField'; import Empty from '../Empty'; import Footer from '../Footer'; @@ -37,9 +37,8 @@ function CartContent(props) { cartItems, messages, isUserLoggedIn, currency, flags, hasPromotionCoupons, isDirectShipOnly, } = props; const [isPaymentBarVisible, setIsPaymentBarVisible] = React.useState(true); - const { isLoading: getIsLoading } = React.useContext(LoadingContext); + const { isFetching } = useSelector(getCart); - const isLoading = getIsLoading(CART_PATH); const hasItems = (cartItems.length > 0); const hasMessages = (messages.length > 0); const cartItemsSorted = sortCartItems(cartItems); @@ -58,7 +57,6 @@ function CartContent(props) { currency, config, isUserLoggedIn, - isLoading, flags, hasPromotionCoupons, isDirectShipOnly, @@ -116,7 +114,7 @@ function CartContent(props) {