Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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));
};
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;
}
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;
}
const changeSort = newSort => (dispatch, getState) => {
const state = getState();
const oldSort = getSortOrder(state);
if (newSort === oldSort) {
return;
}
// Change the sort order
dispatch(changeSortOrder(newSort));
};
export const resetScrollTopBySort = sortOrder => (dispatch, getState) => {
if (getSortOrder(getState()) !== sortOrder) {
dispatch(setViewScrollToTop());
}
};
state => getSortOrder(state) || DEFAULT_SORT,
getActiveFilters,
const getResultHash = state => generateResultHash({
pipeline: 'getLiveshoppingProducts',
sort: getSortOrder(state),
}, true, false);
const resetScrollTopBySort = sortOrder => (dispatch, getState) => {
if (getSortOrder(getState()) !== sortOrder) {
dispatch(setViewTop());
}
};
(state, props) => getSortOrder(state, props) || DEFAULT_SORT,
getActiveFilters,
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,
};
};