How to use the @shopgate/pwa-common/selectors/history.getSortOrder 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 / components / FilterBar / components / Content / components / Sort / actions / changeSort.js View on Github external
const changeSort = newSort => (dispatch, getState) => {
  const state = getState();
  const oldSort = getSortOrder(state);

  if (newSort === oldSort) {
    return;
  }

  // Change the sort order
  dispatch(changeSortOrder(newSort));

  // Fetch new products.
  dispatch(getProducts());

  // Reset the scroll top position of the page.
  dispatch(setViewTop(true));
};
github shopgate / pwa / themes / theme-gmd / widgets / selectors.js View on Github external
const getResultHash = (state, type, params, id) => {
  let hashParams = {};
  const currentSort = getSortOrder(state);
  const { value, sort = currentSort } = params;
  const transformedSort = transformDisplayOptions(sort);

  // Create the hash parameters based on the query type and parameters.
  switch (type) {
    // Product highlights
    case 1: {
      hashParams = {
        id,
        pipeline: pipelines.SHOPGATE_CATALOG_GET_HIGHLIGHT_PRODUCTS,
        sort: transformedSort,
      };

      break;
    }
github shopgate / pwa / widgets / selectors.js View on Github external
const getResultHash = (state, type, params, id) => {
  let hashParams = {};
  const currentSort = getSortOrder(state);
  const { value, sort = currentSort } = params;
  const transformedSort = transformDisplayOptions(sort);

  // Create the hash parameters based on the query type and parameters.
  switch (type) {
    // Product highlights
    case 1: {
      hashParams = {
        id,
        pipeline: pipelines.SHOPGATE_CATALOG_GET_HIGHLIGHT_PRODUCTS,
        sort: transformedSort,
      };

      break;
    }
github shopgate / pwa / themes / theme-gmd / components / FilterBar / components / Content / components / Sort / actions / changeSort.js View on Github external
const changeSort = newSort => (dispatch, getState) => {
  const state = getState();
  const oldSort = getSortOrder(state);

  if (newSort === oldSort) {
    return;
  }

  // Change the sort order
  dispatch(changeSortOrder(newSort));
};
github shopgate / pwa / components / Navigator / actions / index.js View on Github external
export const resetScrollTopBySort = sortOrder => (dispatch, getState) => {
  if (getSortOrder(getState()) !== sortOrder) {
    dispatch(setViewScrollToTop());
  }
};
github shopgate / pwa / libraries / commerce / product / selectors / product.js View on Github external
  state => getSortOrder(state) || DEFAULT_SORT,
  getActiveFilters,
github shopgate / pwa / widgets / Liveshopping / selectors.js View on Github external
const getResultHash = state => generateResultHash({
  pipeline: 'getLiveshoppingProducts',
  sort: getSortOrder(state),
}, true, false);
github shopgate / pwa / components / Navigator / actions / resetScrollTopBySort.js View on Github external
const resetScrollTopBySort = sortOrder => (dispatch, getState) => {
  if (getSortOrder(getState()) !== sortOrder) {
    dispatch(setViewTop());
  }
};
github shopgate / pwa / libraries / commerce / product / selectors / product.js View on Github external
  (state, props) => getSortOrder(state, props) || DEFAULT_SORT,
  getActiveFilters,
github shopgate / pwa / libraries / commerce / product / selectors / product.js View on Github external
export const getPopulatedProductsResult = (state, props, hash, result) => {
  const sort = getSortOrder(state) || DEFAULT_SORT;
  let products = [];
  let totalProductCount = !hash ? 0 : null;

  if (result && result.products) {
    totalProductCount = result.totalResultCount;
    products = result.products.map(productId => getProductById(state, { productId }).productData);
  }

  return {
    products,
    totalProductCount,
    sort,
    hash,
  };
};