fix: filtering
This commit is contained in:
parent
ca097dfb65
commit
db613357a7
|
@ -0,0 +1,14 @@
|
||||||
|
import { Genre } from "@prisma/client";
|
||||||
|
import { FilterFn, Row } from "@tanstack/react-table";
|
||||||
|
|
||||||
|
export const genrePickerFilterFn = (row: Row<any>, columnId: string, filterValue: any) => {
|
||||||
|
|
||||||
|
const genres: Genre[] = row.getValue(columnId)
|
||||||
|
|
||||||
|
for (let index = 0; index < genres.length; index++) {
|
||||||
|
if (genres[genres.length - 1].name.includes(filterValue)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import { selectCol } from "app/ui/tables/selectColumn"
|
||||||
import NumberInputCell from "app/ui/tables/inputs/numberInput"
|
import NumberInputCell from "app/ui/tables/inputs/numberInput"
|
||||||
import { pubSchema } from "app/ui/forms/schemas"
|
import { pubSchema } from "app/ui/forms/schemas"
|
||||||
import GenrePickerInputCell from "app/ui/tables/inputs/genrePickerInput"
|
import GenrePickerInputCell from "app/ui/tables/inputs/genrePickerInput"
|
||||||
|
import { genrePickerFilterFn } from "app/lib/filterFns"
|
||||||
|
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<PubWithGenres>()
|
const columnHelper = createColumnHelper<PubWithGenres>()
|
||||||
|
@ -66,10 +67,10 @@ export const columns: ColumnDef<PubWithGenres>[] = [
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
cell: GenrePickerInputCell,
|
cell: GenrePickerInputCell,
|
||||||
filterFn: "arrIncludes"
|
filterFn: genrePickerFilterFn
|
||||||
//TODO - write custom filter function, to account for an array of objects
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
accessorKey: "query_after_days",
|
accessorKey: "query_after_days",
|
||||||
header: () => (
|
header: () => (
|
||||||
|
@ -78,6 +79,7 @@ export const columns: ColumnDef<PubWithGenres>[] = [
|
||||||
<span className="sm:hidden"><Clock /></span>
|
<span className="sm:hidden"><Clock /></span>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
|
enableColumnFilter: false,
|
||||||
cell: cell => (
|
cell: cell => (
|
||||||
<>
|
<>
|
||||||
{/* @ts-ignore */}
|
{/* @ts-ignore */}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import NumberInputCell from "app/ui/tables/inputs/numberInput"
|
||||||
import { storySchema } from "app/ui/forms/schemas"
|
import { storySchema } from "app/ui/forms/schemas"
|
||||||
import { TextInputCell } from "app/ui/tables/inputs/textInput"
|
import { TextInputCell } from "app/ui/tables/inputs/textInput"
|
||||||
import GenrePickerInputCell from "app/ui/tables/inputs/genrePickerInput"
|
import GenrePickerInputCell from "app/ui/tables/inputs/genrePickerInput"
|
||||||
|
import { genrePickerFilterFn } from "app/lib/filterFns"
|
||||||
const columnHelper = createColumnHelper<StoryWithGenres>()
|
const columnHelper = createColumnHelper<StoryWithGenres>()
|
||||||
|
|
||||||
export const columns: ColumnDef<StoryWithGenres>[] = [
|
export const columns: ColumnDef<StoryWithGenres>[] = [
|
||||||
|
@ -78,7 +79,7 @@ export const columns: ColumnDef<StoryWithGenres>[] = [
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
cell: GenrePickerInputCell,
|
cell: GenrePickerInputCell,
|
||||||
filterFn: "arrIncludes",
|
filterFn: genrePickerFilterFn,
|
||||||
meta: {}
|
meta: {}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue