-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement basic filtering in UsersView
Unfortunately this still seems to be a bit buggy: Clearing the filter text causes a bunch of duplicate key errors, even though it is unclear whether the issue is with `useAsyncList` or NextUI's internal table rendering.
- Loading branch information
Showing
3 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export interface Filter { | ||
key: string | number; | ||
text: string; | ||
} | ||
|
||
/** Filters elements according to the given filter. */ | ||
export function filtered<T>(elements: T[], filter: Filter): T[] { | ||
const filterText = filter.text.toLowerCase(); | ||
return elements.filter((element: any) => { | ||
const value = element[filter.key]; | ||
const json = JSON.stringify(value).toLowerCase(); | ||
return json.includes(filterText); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters