Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Jan 25, 2024
1 parent 7c201c2 commit 407c912
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/components/sectionList/listView/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SectionName } from '../../../lib'
import type { ModelPropertyDescriptor } from '../../../lib'
import type { FilterDescriptor, ModelPropertyDescriptor } from '../../../lib'

export interface ModelListView {
name: string
sectionModel: string
columns: ReadonlyArray<ModelPropertyDescriptor>
filters: ReadonlyArray<ModelPropertyDescriptor>
filters: ReadonlyArray<FilterDescriptor>
}

export type ModelListViews = {
Expand Down
6 changes: 3 additions & 3 deletions src/components/sectionList/listView/useModelListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ const parseViewToModelListView = (
return columnConfig as NonNullable<typeof columnConfig>
})

const filters = viewConfig.filters.available.filter((col) =>
parsedView.filters.includes(col.path)
const filters = viewConfig.filters.available.filter((filterDescriptor) =>
parsedView.filters.includes(filterDescriptor.filterKey)
)

return {
Expand All @@ -95,7 +95,7 @@ const formatViewToDataStore = (
const savedView = {
...view,
columns: view.columns.map((c) => c.path),
filters: view.filters.map((f) => f.path),
filters: view.filters.map((f) => f.filterKey),
}

return savedView
Expand Down
4 changes: 3 additions & 1 deletion src/lib/sectionList/filters/filterConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export const filterParamsSchema = z
.object({
[IDENTIFIABLE_KEY]: z.string(),
aggregationType: z.array(z.nativeEnum(DataElement.aggregationType)),
categoryCombo: zodArrayIds,
dataSet: zodArrayIds,
domainType: z.array(z.nativeEnum(DataElement.domainType)),
valueType: z.array(z.string()),
dataSet: zodArrayIds,
})
.partial()

Expand All @@ -26,6 +27,7 @@ export const filterQueryParamType = {
domainType: CustomDelimitedArrayParam,
valueType: CustomDelimitedArrayParam,
dataSet: CustomDelimitedArrayParam,
categoryCombo: CustomDelimitedArrayParam,
} as const satisfies QueryParamsConfigMap

export const validFilterKeys = Object.keys(filterQueryParamType)
Expand Down
6 changes: 1 addition & 5 deletions src/lib/sectionList/filters/useFilterQueryParams.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { useMemo } from 'react'
import {
useModelSectionHandleOrThrow,
useSectionHandle,
} from './../../routeUtils/useSectionHandle'
import { ParsedFilterParams } from './filtersQueryParamSimple'
import { useSectionHandle } from './../../routeUtils/useSectionHandle'
import { parseFiltersToQueryParams } from './parseFiltersToQueryParams'
import { useSectionListFilters } from './useSectionListFilters'

Expand Down
1 change: 0 additions & 1 deletion src/pages/dataElements/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
SectionListWrapper,
DomainTypeSelectionFilter,
ValueTypeSelectionFilter,
useQueryParamsForModelGist,
} from '../../components'
import { useModelListView } from '../../components/sectionList/listView'
import { useSchemaFromHandle, useParamsForDataQuery } from '../../lib/'
Expand Down

0 comments on commit 407c912

Please sign in to comment.