Skip to content

Commit

Permalink
feat: add caught filter/sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvein committed Mar 27, 2020
1 parent 59f4843 commit 289878c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/pages/index.js
Expand Up @@ -314,8 +314,7 @@ const columns = [
Header: 'Caught',
accessor: 'caught',
width: 75,
disableFilters: true,
disableSortBy: true,
sortType: 'basic',
Cell: ({ cell, onCaughtAnimal }) => {
const animal = cell.row.values.name

Expand All @@ -329,6 +328,24 @@ const columns = [
</Flex>
)
},
filter: (rows, id, filterValue) => {
if (!filterValue) return rows

return rows.filter((row) => !row.values.caught)
},
Filter: ({ column: { setFilter, filterValue } }) => {
return (
<FormControl mr={2}>
Not caught
<Stack height={10} isInline>
<Checkbox
isChecked={filterValue}
onChange={(e) => setFilter(e.target.checked)}
/>
</Stack>
</FormControl>
)
},
},
]

Expand Down

0 comments on commit 289878c

Please sign in to comment.