subman-nextjs/src/app/publication/columns.tsx

69 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-06-20 08:35:25 +00:00
"use client"
import { ColumnDef, createColumnHelper } from "@tanstack/react-table"
import { ArrowUpDown, MoreHorizontal } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Badge } from "@/components/ui/badge"
import { Trash2, Search } from "lucide-react"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import Link from "next/link"
import { PubsWithGenres } from "./page"
2024-06-20 09:39:35 +00:00
import { DialogClose } from "@radix-ui/react-dialog"
2024-06-22 18:12:05 +00:00
import { actions } from "app/ui/tables/actions"
2024-06-30 15:36:44 +00:00
import { TextInputCell } from "app/ui/inputs/textInput"
2024-06-30 18:28:02 +00:00
import { selectCol } from "app/ui/tables/selectColumn"
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-06-30 15:36:44 +00:00
cell: TextInputCell
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-06-30 15:36:44 +00:00
cell: TextInputCell
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", {
cell: props => {
const genres = props.getValue()
.map(e => <Badge>{e.name}</Badge>)
return genres
},
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",
header: "Query After (days)"
},
2024-06-20 08:35:25 +00:00
]