Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fpbrault committed Feb 6, 2025
1 parent 38cf798 commit 0da0de2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getQ,
getSortCriteria,
getFacets,
getTab,
} from '../../../features/parameter-manager/parameter-manager-selectors.js';
import {getQueryInitialState} from '../../../features/query/query-state.js';
import {
Expand Down Expand Up @@ -185,20 +186,6 @@ function facetIsEnabled(state: CoreEngine['state']) {
};
}

function getTab<Section, Value>(
section: Section | undefined,
tabSelector: (state: Section) => Value,
initialState: Value
) {
if (section === undefined) {
return {};
}

const tab = tabSelector(section);
const shouldInclude = tab !== initialState;
return shouldInclude ? {tab} : {};
}

export function getSelectedValues(request: FacetRequest) {
return request.currentValues
.filter((fv) => fv.state === 'selected')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,17 @@ export function getFacets<Value, Request, Parameters>(

return Object.keys(facets).length ? {[out]: facets} : {};
}

export function getTab<Section>(
section: Section | undefined,
tabSelector: (tabSet: Section) => string,
initialState: string
) {
if (section === undefined) {
return {};
}

const tab = tabSelector(section);
const shouldInclude = tab !== initialState;
return shouldInclude ? {tab} : {};
}

0 comments on commit 0da0de2

Please sign in to comment.