Skip to content

Commit

Permalink
feat: update formtype filter to constnt select
Browse files Browse the repository at this point in the history
  • Loading branch information
Chisomchima committed Nov 13, 2024
1 parent 85475f6 commit 8722443
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
DOMAIN_TYPE,
getTranslatedProperty,
VALUE_TYPE,
FORM_TYPE,
} from '../../../../lib'
import { ConstantSelectionFilter } from './ConstantSelectionFilter'

Expand All @@ -17,6 +18,15 @@ export const DomainTypeSelectionFilter = () => {
/>
)
}
export const FormTypeFilter = () => {
return (
<ConstantSelectionFilter
label={getTranslatedProperty('formType')}
filterKey="formType"
constants={FORM_TYPE}
/>
)
}

export const ValueTypeSelectionFilter = () => {
return (
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export * from './CategoryFilter'
export * from './CategoryOptionGroupFilter'
export * from './BooleanFilters'
export * from './CategoryOptionFilter'
export * from './FormTypeFilter'
export * from './IndicatorFilter'
8 changes: 8 additions & 0 deletions src/lib/constants/translatedModelConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ export const GEOMETRY_TYPE = {
GEOMETRYCOLLECTION: i18n.t('GeometryCollection'),
}

export const FORM_TYPE = {
CUSTOM: i18n.t('Custom'),
DEFAULT: i18n.t('Default'),
SECTION: i18n.t('Section'),
SECTION_MULTIORG: i18n.t('Section Multi-org'),
}

const allConstantTranslations: Record<string, string> = {
...AGGREGATION_TYPE,
...DOMAIN_TYPE,
...VALUE_TYPE,
...DATA_DIMENSION_TYPE,
...GEOMETRY_TYPE,
...FORM_TYPE,
}

export const getConstantTranslation = (constant: string): string => {
Expand Down
1 change: 1 addition & 0 deletions src/lib/constants/translatedModelProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const TRANSLATED_PROPERTY: Record<string, string> = {
lastUpdatedBy: i18n.t('Last updated by'),
created: i18n.t('Created'),
domainType: i18n.t('Domain type'),
formType: i18n.t('Form type'),
dataSet: i18n.t('Data set'),
lastUpdated: i18n.t('Last updated'),
name: i18n.t('Name'),
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sectionList/filters/filterConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BooleanParam, StringParam } from 'use-query-params'
import { z } from 'zod'
import { Category, DataElement } from '../../../types/generated'
import { Category, DataElement, DataSet } from '../../../types/generated'
import { KeysOfValue } from '../../../types/utility'
import { IDENTIFIABLE_FILTER_KEY } from '../../constants'
import { isValidUid, parseAccessString } from '../../models'
Expand All @@ -15,7 +15,7 @@ export const filterParamsSchema = z
aggregationType: z.array(z.nativeEnum(DataElement.aggregationType)),
categoryCombo: zodArrayIds,
category: zodArrayIds,
formType: zodArrayIds,
formType: z.array(z.nativeEnum(DataSet.formType)),
categoryOption: zodArrayIds,
categoryOptionGroup: zodArrayIds,
dataSet: zodArrayIds,
Expand Down
1 change: 0 additions & 1 deletion src/lib/sectionList/filters/parseFiltersToQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const filterToQueryParamMap: FilterToQueryParamsMap = {
identifiable: (value) => `identifiable:token:${value}`,
category: (value) => inFilter('categories.id', value),
categoryOption: (value) => inFilter('categoryOptions.id', value),
indicatorType: (value) => inFilter('indicatorType.id', value),
categoryCombo: (value, section) => {
if (section.name === 'category') {
return inFilter('categoryCombos.id', value)
Expand Down

0 comments on commit 8722443

Please sign in to comment.