How can I implement logic for filter dropdown?
In the application is page when we can manage users, like: create, edit, remove and show. Also there is option to disable user.
There is Table for Users, on which I need to implement filter.
I need to filter by users which are "Active" that mean they have property disable: false. And "Deactive" users which have disabled: true
Here is how my Filter dropdown array looks:
const statusOptions = [
{
key: 'all',
text: 'All',
value: 'all'
},
{
key: 'disabled',
text: 'Active',
value: false
},
{
key: 'disabled',
text: 'Deactive',
value: true
}
]
<Form.Dropdown
label="Filter by Status"
name="disabled"
selection
onChange={this.handleFieldChange}
value={disabled || 'all'}
fluid
options={statusOptions}
/>
Handle Field Change function:
handleFieldChange = (e, { name, value } = {}) => {
const { onChange } = this.props
this.setState((current = {}) => {
const next = {
...current,
[name]: value
}
onChange && onChange(next)
return next
})
}
Any idea how to organize this filter logic on correct way?