Skip to content
Snippets Groups Projects
Commit 86096805 authored by Tadeusz Miesiąc's avatar Tadeusz Miesiąc
Browse files

refactor(query selector): improved code readability

parent 6b0a3cf0
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!101fix(search bar): fixed unexpected search bar openings & lack of search value in input on load
Pipeline #84458 passed
......@@ -16,25 +16,20 @@ export const queryDataParamsSelector = createSelector(
{ modelId, backgroundId, position },
activeOverlaysId,
): QueryDataParams => {
const joinedSearchValue = searchValue.join(';');
const shouldIncludeSearchValue = searchValue.length > ZERO && joinedSearchValue;
const shouldIncludeOverlaysId = activeOverlaysId.length > ZERO;
const queryDataParams: QueryDataParams = {
perfectMatch,
modelId,
backgroundId,
...position.last,
...(shouldIncludeSearchValue ? { searchValue: joinedSearchValue } : {}),
...(shouldIncludeOverlaysId ? { overlaysId: activeOverlaysId.join(',') } : {}),
};
/** prevent searchValueQuery from being empty */
if (searchValue.length > ZERO) {
const joinedSearchValue = searchValue.join(';');
if (joinedSearchValue) {
queryDataParams.searchValue = joinedSearchValue;
}
}
if (activeOverlaysId.length > ZERO) {
queryDataParams.overlaysId = activeOverlaysId.join(',');
}
return queryDataParams;
},
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment