Skip to content

Commit

Permalink
fix: add missing availableValues translation in filters
Browse files Browse the repository at this point in the history
  • Loading branch information
dziraf committed Jan 18, 2024
1 parent 660b43a commit 63958ca
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { FormGroup, Input, Select } from '@adminjs/design-system'
import allowOverride from '../../../hoc/allow-override.js'
import { FilterPropertyProps } from '../base-property-props.js'
import PropertyLabel from '../utils/property-label/property-label.js'
import { useTranslation } from '../../../hooks/use-translation.js'

const Filter: React.FC<FilterPropertyProps> = (props) => {
const { property, onChange, filter } = props
const { translateProperty } = useTranslation()

const handleInputChange = (event) => {
onChange(property.path, event.target.value)
Expand All @@ -21,13 +23,17 @@ const Filter: React.FC<FilterPropertyProps> = (props) => {
const filterKey = `filter-${property.path}`
const value = filter[property.path] || ''
if (property.availableValues) {
const availableValues = property.availableValues.map((v) => ({
...v,
label: translateProperty(v.label),
}))
const selected = property.availableValues.find((av) => av.value === value)
return (
<Select
variant="filter"
value={typeof selected === 'undefined' ? '' : selected}
isClearable
options={property.availableValues}
options={availableValues}
onChange={handleSelectChange}
/>
)
Expand Down

0 comments on commit 63958ca

Please sign in to comment.