How to use @shopgate/pwa-common-commerce - 10 common examples

To help you get started, we’ve selected a few @shopgate/pwa-common-commerce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shopgate / pwa / pages / Reviews / subscriptions.js View on Github external
subscribe(reviewsRouteDidEnter$, ({ dispatch, getState }) => {
    const currentCount = getCurrentReviewCount(getState());
    if (currentCount >= REVIEW_ITEMS_PER_PAGE) {
      // No need to fetch.
      return;
    }
    dispatch(fetchReviews(getCurrentBaseProductId(getState()), REVIEW_ITEMS_PER_PAGE));
  });
}
github shopgate / pwa / pages / WriteReview / subscriptions.js View on Github external
subscribe(reviewsRouteDidEnter$, ({ dispatch, getState }) => {
    const state = getState();
    const productId = getCurrentBaseProductId(state);

    if (!state.user.login.isLoggedIn) {
      return;
    }
    // Only dispatch when review is not yet in store
    dispatch(getUserReview(productId));
  });
github shopgate / pwa / libraries / tracking / streams / search.js View on Github external
.switchMap((data) => {
    const { getState } = data;
    const query = getCurrentSearchQuery(getState());

    // Check if products for the current route are already available within Redux.
    const productsLoaded = getProductsResult(
      getState(),
      { searchPhrase: query }
    ).totalProductCount !== null;

    if (!productsLoaded) {
      // Wait for incoming products if they are not available yet.
      return resultsReceived$.first();
    }

    return Observable.of(data);
  })
  .merge(searchRouteReappeared$);
github shopgate / pwa / libraries / tracking / streams / category.js View on Github external
.switchMap((data) => {
    const { action, getState } = data;
    const { categoryId } = action.route.params;

    // Check if products for the current route are already available within Redux.
    const productsLoaded = getProductsResult(
      getState(),
      { categoryId: hex2bin(categoryId) }
    ).totalProductCount !== null;

    if (!productsLoaded) {
      // Wait for incoming products if they are not available yet.
      return productsReceived$.first();
    }

    return Observable.of(data);
  });
github shopgate / pwa / themes / theme-gmd / pages / Product / components / Header / components / CTAButtons / components / CartButton / actions / index.js View on Github external
export const addProductToCart = data => (dispatch, getState) => {
  const state = getState();

  // Transform the options to the required format for the pipeline request.
  const options = getAddToCartOptions(state, data);
  const { productId, quantity } = data;

  dispatch(addProductsToCart([{
    productId,
    quantity,
    ...(options) && { options },
  }]));
};
github shopgate / pwa / themes / theme-ios11 / pages / Product / components / AddToCartBar / actions / index.js View on Github external
export const addProductToCart = data => (dispatch, getState) => {
  const state = getState();

  // Transform the options to the required format for the pipeline request.
  const options = getAddToCartOptions(state, data);
  const { productId, quantity } = data;

  dispatch(addProductsToCart([{
    productId,
    quantity,
    ...(options) && { options },
  }]));
};
github shopgate / pwa / pages / Product / subscriptions.js View on Github external
subscribe(routeDidEnter(ITEM_PATH), ({ dispatch, getState }) => {
    const productId = getCurrentBaseProductId(getState());
    dispatch(getProduct(productId));
  });
github shopgate / pwa / pages / Product / subscriptions.js View on Github external
subscribe(shouldFetchReviews$, ({ dispatch, getState }) => {
      const baseProductId = getCurrentBaseProductId(getState());
      if (baseProductId) {
        dispatch(getProductReviews(baseProductId, REVIEW_PREVIEW_COUNT));
      }
    });
  }
github shopgate / pwa / themes / theme-ios11 / pages / Product / actions / getProductData.js View on Github external
(dispatch, getState) => {
    const state = getState();
    const currentProductId = getCurrentBaseProductId(state);
    const productId = selectedVariantId || currentProductId;

    if (!productId) {
      return;
    }

    dispatch(requestProductData(productId, selectedVariantId));
    dispatch(getProduct(productId));
  };
github shopgate / pwa / themes / theme-gmd / pages / Reviews / components / LoadMore / connector.js View on Github external
const mapStateToProps = (state, props) => ({
  currentReviewCount: getCurrentReviewCount(state, props),
  isFetching: getReviewsFetchingState(state, props),
  productId: getCurrentBaseProductId(state, props),
  totalReviewCount: getReviewsTotalCount(state, props),
});

@shopgate/pwa-common-commerce

Commerce library for the Shopgate Connect PWA.

Apache-2.0
Latest version published 2 days ago

Package Health Score

70 / 100
Full package analysis