How to use the @shopgate/pwa-common/selectors/router.getCurrentRoute 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 / libraries / common / subscriptions / router.js View on Github external
location,
              state: routeState,
            },
          },
        }));

        return;
      }
    }

    // Check for a redirect and change location if one is found.
    let redirect = redirects.getRedirect(location);

    if (redirect) {
      if (typeof redirect === 'function' || redirect instanceof Promise) {
        const { pathname } = getCurrentRoute(state);
        LoadingProvider.setLoading(pathname);

        const pattern = router.findPattern(location.split('?')[0]);
        const { transform } = router.patterns[pattern] || {};
        const route = new Route({
          pathname: location,
          pattern,
          routeState,
          transform,
        });

        try {
          redirect = await redirect({
            ...params,
            action: {
              ...params.action,
github shopgate / pwa / libraries / commerce / product / actions / changeSortOrder.js View on Github external
const changeSortOrder = sort => (dispatch, getState) => {
  const { query, state } = getCurrentRoute(getState());
  const newQuery = parseObjectToQueryString({
    ...query,
    sort,
  });

  dispatch(historyReplace({
    pathname: `${window.location.pathname}${newQuery}`,
    state,
  }));
};
github shopgate / pwa / themes / theme-gmd / components / FilterBar / components / Content / actions / openFilterRoute.js View on Github external
const openFilterRoute = () => (dispatch, getState) => {
  const {
    id,
    params: { categoryId },
    query,
    state,
  } = getCurrentRoute(getState());

  const forwardState = {
    filters: state.filters || null,
    parentId: id,
  };

  if (categoryId) {
    dispatch(historyPush({
      pathname: `${CATEGORY_PATH}/${categoryId}/filter`,
      state: forwardState,
    }));
  } else if (query.s) {
    const queryString = parseObjectToQueryString(query);

    dispatch(historyPush({
      pathname: `${SEARCH_PATH}/filter${queryString}`,
github shopgate / pwa / themes / theme-ios11 / components / TabBar / subscriptions.js View on Github external
subscribe(routeDidEnter$, ({ dispatch, getState }) => {
    const { pattern } = getCurrentRoute(getState());
    dispatch(isTabBarVisible(getState(), pattern) ? enableTabBar() : disableTabBar());
  });
github shopgate / pwa / libraries / common / subscriptions / helpers / handleLinks.js View on Github external
export const handleAppRedirect = (historyAction, state) => {
  const { pathname } = getCurrentRoute(state);

  if (authRoutes.isProtector(pathname) && historyAction === ACTION_REPLACE) {
    /**
     * A replace action on a protector route indicates that the authentication was successful.
     * So the protector route can be popped from the history stack.
     */
    router.pop();
  }
};
github shopgate / pwa / libraries / tracking / subscriptions / pages.js View on Github external
const callPageViewTracker = ({ getState }) => {
  const state = getState();
  const getTrackingData = makeGetTrackingData();

  track(
    'pageview',
    getTrackingData(state, getCurrentRoute(state)),
    state
  );
};
github shopgate / pwa / themes / theme-gmd / pages / Search / streams.js View on Github external
.filter(({ getState }) => {
    const { pattern } = getCurrentRoute(getState());
    return (pattern === SEARCH_PATH);
  });
github shopgate / pwa / themes / theme-ios11 / pages / Search / streams.js View on Github external
.filter(({ getState }) => {
    const { pattern } = getCurrentRoute(getState());
    return (pattern === SEARCH_PATH);
  });
github shopgate / pwa / libraries / commerce / product / streams / index.js View on Github external
.filter(({ action, getState }) => {
    const route = getCurrentRoute(getState());

    if (typeof action.productData === 'undefined' || typeof action.productData.id === 'undefined') {
      return false;
    }

    if (!route.params.productId && !route.state.productId) {
      return false;
    }

    if (route.state.productId) {
      return action.productData.id === route.state.productId;
    }

    return action.productData.id === hex2bin(route.params.productId);
  });
github shopgate / pwa / themes / theme-ios11 / pages / Category / streams.js View on Github external
.filter(({ getState }) => {
    const { pattern } = getCurrentRoute(getState());
    return (pattern === `${CATEGORY_PATH}/:categoryId`);
  });