Skip to content

Commit

Permalink
fix(misc): read decoded sort from query params. misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjithkumar017 committed May 11, 2021
1 parent 771c894 commit 9064f71
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions demo/src/components/CombinedFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const transform = function () {
return this;
};

const onFacetClick = (facet, facetType, isSelected) => {
console.log('Facet change :', facet, facetType, isSelected);
const onFacetClick = (facetObj, eventType) => {
console.log('Facet change :', facetObj, eventType);
scrollTop();
return true;
};
Expand Down
5 changes: 3 additions & 2 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export const conditionalRenderer = (

export const executeCallback = (callback, parameters, onFinish) => {
if (typeof callback === 'function') {
if (callback(...parameters)) {
onFinish();
const result = callback(...parameters);
if (result) {
onFinish(result);
}
} else {
onFinish();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pageSize/PageSizeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PageSizeContainer extends React.PureComponent {
} = this.props;
const { sizeOptions } = this.state;
const { rows = false } = unbxdCore.getQueryParams();
const numberOfProducts = Number(rows);
const numberOfProducts = Number(rows || size);
if (!isNaN(numberOfProducts)) {
const updatedSizeOptions = getUpdatedOptions(
sizeOptions,
Expand Down
14 changes: 7 additions & 7 deletions src/modules/sort/SortContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ class SortContainer extends React.Component {

let sortOn = null;
const { sort = '' } = unbxdCore.getQueryParams();
if (typeof sort === 'string' && sort.length) {
const [field, order] = sort.split(' ');
const decodedSort = sort ? decodeURI(sort) : '';
if (typeof decodedSort === 'string' && decodedSort.length) {
const [field, order] = decodedSort.split(' ');
sortOn = { field, order };
const formattedSort = `${field}|${order}`;
const formattedSortByOptions = sortOptions.map((sortByoption) =>
Expand Down Expand Up @@ -74,22 +75,21 @@ class SortContainer extends React.Component {
} = this.props;

const { sort } = unbxdCore.getQueryParams();
let sortOn = null;
const decodedSort = sort ? decodeURI(sort) : '';

if (
unbxdCoreStatus !== prevProps.unbxdCoreStatus &&
unbxdCoreStatus === searchStatus.LOADING &&
sortState !== sort &&
sortState !== decodedSort &&
prevProps.sort === sortState
) {
if (sort === undefined) {
if (decodedSort === undefined) {
this.setState({ sortBy: { value: '' } });
setSortConfiguration({
sortBy: ``
});
} else {
const [field, order] = sort.split(' ');
sortOn = { field, order };
const [field, order] = decodedSort.split(' ');
const formattedSort = `${field}|${order}`;
const formattedSortByOptions = sortOptions.map((sortByoption) =>
getFormattedSort(sortByoption, this.state.sortBy)
Expand Down

0 comments on commit 9064f71

Please sign in to comment.