Skip to content

Commit

Permalink
IBX-8392: [Image picker] Sorting by name and date does not work (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasOsti committed Jun 25, 2024
1 parent fe389e1 commit d20ae73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const Search = ({ itemsPerPage }) => {
const [selectedLanguage, setSelectedLanguage] = useState(firstLanguageCode);
const prevSearchText = useRef(null);
const [isLoading, data, searchByQuery] = useSearchByQueryFetch();

const search = () => {
const shouldResetOffset = prevSearchText.current !== searchText && offset !== 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const useSearchByQueryFetch = () => {
const restInfo = useContext(RestInfoContext);
const [, dispatchLoadedLocationsAction] = useContext(LoadedLocationsMapContext);
const [{ isLoading, data }, dispatch] = useReducer(searchByQueryReducer, { isLoading: false, data: {} });

const searchByQuery = useCallback(
(
searchText,
Expand All @@ -33,6 +34,8 @@ export const useSearchByQueryFetch = () => {
limit,
offset,
languageCode,
sortClause = null,
sortOrder = null,
imageCriterionData = null,
aggregations = {},
filters = {},
Expand Down Expand Up @@ -81,7 +84,10 @@ export const useSearchByQueryFetch = () => {
}

dispatch({ type: SEARCH_START });
return findLocationsBySearchQuery({ ...restInfo, query, aggregations, filters, limit, offset, languageCode }, handleFetch);
return findLocationsBySearchQuery(
{ ...restInfo, query, aggregations, filters, sortClause, sortOrder, limit, offset, languageCode },
handleFetch,
);
},
[restInfo, dispatch],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export const findLocationsBySearchQuery = (
query,
aggregations,
filters,
sortClause = 'DatePublished',
sortOrder = 'ascending',
limit = QUERY_LIMIT,
offset = 0,
languageCode = null,
Expand All @@ -197,7 +199,12 @@ export const findLocationsBySearchQuery = (
useAlwaysAvailable,
LocationQuery: {
FacetBuilders: {},
SortClauses: {},
SortClauses:
sortClause && sortOrder
? {
[sortClause]: sortOrder,
}
: {},
Query: query,
Aggregations: aggregations,
Filters: filters,
Expand Down Expand Up @@ -508,7 +515,6 @@ export const findSuggestions = (
},
},
});

const request = new Request(ENDPOINT_CREATE_VIEW, {
method: 'POST',
headers: getRequestHeaders({
Expand Down

0 comments on commit d20ae73

Please sign in to comment.