2024-06-20 08:35:25 +00:00
|
|
|
"use client"
|
|
|
|
import { ColumnDef, createColumnHelper } from "@tanstack/react-table"
|
2024-07-02 22:41:20 +00:00
|
|
|
import { ArrowUpDown } from "lucide-react"
|
2024-06-20 08:35:25 +00:00
|
|
|
import { Button } from "@/components/ui/button"
|
|
|
|
import { Badge } from "@/components/ui/badge"
|
|
|
|
import { PubsWithGenres } from "./page"
|
2024-07-02 20:16:17 +00:00
|
|
|
import { TextInputCell } from "app/ui/tables/inputs/textInput"
|
2024-06-30 18:28:02 +00:00
|
|
|
import { selectCol } from "app/ui/tables/selectColumn"
|
2024-07-02 20:16:17 +00:00
|
|
|
import NumberInputCell from "app/ui/tables/inputs/numberInput"
|
2024-07-02 20:52:10 +00:00
|
|
|
import { formSchema } from "app/ui/forms/pub"
|
2024-07-24 20:41:46 +00:00
|
|
|
import GenrePickerInputCell from "app/ui/tables/inputs/genrePickerInput"
|
2024-07-02 20:16:17 +00:00
|
|
|
|
2024-06-20 08:35:25 +00:00
|
|
|
|
|
|
|
const columnHelper = createColumnHelper<PubsWithGenres>()
|
|
|
|
|
|
|
|
export const columns: ColumnDef<PubsWithGenres>[] = [
|
2024-06-30 18:28:02 +00:00
|
|
|
selectCol,
|
2024-06-20 08:35:25 +00:00
|
|
|
{
|
|
|
|
accessorKey: "title",
|
|
|
|
header: ({ column }) => {
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
variant="ghost"
|
|
|
|
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
|
|
|
>
|
|
|
|
Title
|
|
|
|
<ArrowUpDown className="ml-2 h-4 w-4" />
|
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
},
|
2024-07-02 20:52:10 +00:00
|
|
|
cell: TextInputCell,
|
|
|
|
meta: { formSchema }
|
2024-06-20 08:35:25 +00:00
|
|
|
},
|
2024-06-20 21:21:37 +00:00
|
|
|
|
2024-06-20 08:35:25 +00:00
|
|
|
{
|
|
|
|
accessorKey: "link",
|
|
|
|
header: "Link",
|
2024-07-02 20:52:10 +00:00
|
|
|
cell: TextInputCell,
|
|
|
|
meta: { formSchema }
|
2024-06-20 08:35:25 +00:00
|
|
|
},
|
2024-06-20 21:21:37 +00:00
|
|
|
|
2024-06-20 08:35:25 +00:00
|
|
|
columnHelper.accessor("genres", {
|
2024-07-24 20:41:46 +00:00
|
|
|
cell: GenrePickerInputCell,
|
2024-06-20 08:35:25 +00:00
|
|
|
filterFn: "arrIncludes"
|
|
|
|
//TODO - write custom filter function, to account for an array of objects
|
|
|
|
}),
|
2024-06-20 21:21:37 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
accessorKey: "query_after_days",
|
2024-06-30 21:22:46 +00:00
|
|
|
header: "Query After (days)",
|
2024-07-02 20:52:10 +00:00
|
|
|
cell: NumberInputCell,
|
2024-06-30 21:22:46 +00:00
|
|
|
meta: {
|
2024-07-02 20:52:10 +00:00
|
|
|
step: 10,
|
|
|
|
formSchema
|
2024-06-30 21:22:46 +00:00
|
|
|
},
|
2024-06-20 08:35:25 +00:00
|
|
|
|
2024-07-02 20:52:10 +00:00
|
|
|
},
|
2024-06-20 08:35:25 +00:00
|
|
|
]
|
|
|
|
|