How to use the @shopgate/pwa-common/selectors/history.getHistoryPathname function in @shopgate/pwa-common

To help you get started, we’ve selected a few @shopgate/pwa-common 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 / Favorites / subscriptions.js View on Github external
subscribe(favoritesWillRemoveItem$, ({ dispatch, action, getState }) => {
    if (getHistoryPathname(getState()) !== FAVORITES_PATH) {
      // No toast message when favorites is not active page.
      return;
    }
    // Animations are too fast. This should wait a little bit.
    setTimeout(() => {
      dispatch(createToast({
        action: 'common.undo',
        actionOnClick: addFavorites(action.productId),
        duration: 2500,
        message: 'favorites.removed',
        replaceable: true,
      }));
    }, FAVORITES_SHOW_TOAST_DELAY);
  });
}
github shopgate / pwa / filter / actions / index.js View on Github external
export const applyFilters = () => (dispatch, getState) => {
  dispatch(commitTemporaryFilters());

  const path = getHistoryPathname(getState());

  if (path.startsWith(`${FILTER_PATH}/`)) {
    dispatch(goBackHistory(2));
  } else if (path.startsWith(FILTER_PATH)) {
    dispatch(goBackHistory(1));
  }
};
github shopgate / pwa / pages / Category / components / Products / actions / getProducts.js View on Github external
const getProducts = (offset = 0) => (dispatch, getState) => {
  const pathname = getHistoryPathname(getState());

  if (pathname.startsWith(CATEGORY_PATH)) {
    dispatch(fetchCategoryProducts(offset));
  } else if (pathname.startsWith(SEARCH_PATH)) {
    dispatch(getSearchResults(offset));
  }
};
github shopgate / pwa / components / View / selectors / index.js View on Github external
export const isCurrentViewLoading = state => isViewLoading(state, getHistoryPathname(state));
github shopgate / pwa / pages / Product / subscriptions.js View on Github external
      .filter(({ getState }) => getHistoryPathname(getState()).startsWith(ITEM_PATH))
      .merge(successReviewSubmit$);
github shopgate / pwa / pages / WriteReview / subscriptions.js View on Github external
subscribe(requestReviewSubmit$, ({ dispatch, getState }) => {
    dispatch(setViewLoading(getHistoryPathname(getState())));
  });
github shopgate / pwa / pages / WriteReview / subscriptions.js View on Github external
subscribe(responseReviewSubmit$, ({ dispatch, getState }) => {
    dispatch(unsetViewLoading(getHistoryPathname(getState())));
  });
github shopgate / pwa / components / View / connector.js View on Github external
const mapStateToProps = state => ({
  navigatorTitle: getTitle(state),
  historyPathname: getHistoryPathname(state),
  viewTop: getTopStatus(state),
});
github shopgate / pwa / libraries / commerce / filter / actions / applyFilters.js View on Github external
const applyFilters = (roundDisplayAmounts = true) => (dispatch, getState) => {
  dispatch(commitTemporaryFilters(roundDisplayAmounts));

  const path = getHistoryPathname(getState());

  if (path.startsWith(`${FILTER_PATH}/`)) {
    dispatch(goBackHistory(2));
  } else if (path.startsWith(FILTER_PATH)) {
    dispatch(goBackHistory(1));
  }
};