Skip to content

Commit

Permalink
refactor: simplify parseFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Jan 25, 2024
1 parent 407c912 commit 36f21a9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/lib/sectionList/filters/parseFiltersToQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const getQueryParamForFilter = (
key: FilterKey,
value: AllValues,
section?: Section
): string => {
): string | undefined => {
if (!value) {
return ''
return undefined
}
if (key === 'identifiable') {
return `identifiable:token:${value}`
Expand All @@ -34,13 +34,13 @@ export const parseFiltersToQueryParams = (
filters: ParsedFilterParams,
section?: Section
): string[] => {
const queryFilters: string[] = []
for (const [key, value] of Object.entries(filters)) {
if (!value) {
continue
}
const filter = getQueryParamForFilter(key as FilterKey, value, section)
queryFilters.push(filter)
}
const queryFilters = Object.entries(filters)
.map(([key, value]) =>
getQueryParamForFilter(key as FilterKey, value, section)
)
.filter(
(queryFilter): queryFilter is string => queryFilter !== undefined
)

return queryFilters
}

0 comments on commit 36f21a9

Please sign in to comment.