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

61 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-06-12 15:15:22 +00:00
"use client"
import { ColumnDef } from "@tanstack/react-table"
2024-06-19 09:34:45 +00:00
import { Genre, Story } from "@prisma/client"
2024-06-12 15:15:22 +00:00
import { ArrowUpDown, MoreHorizontal } from "lucide-react"
import { Button } from "@/components/ui/button"
2024-06-19 09:34:45 +00:00
export const columns: ColumnDef<Story & { genres: Array<Genre> }>[] = [
2024-06-12 15:15:22 +00:00
// {
// accessorKey: "id",
// header: "Id",
// enableHiding: true,
// },
{
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-19 09:34:45 +00:00
2024-06-12 15:15:22 +00:00
},
{
accessorKey: "word_count",
2024-06-19 09:34:45 +00:00
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Word Count
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
)
},
enableColumnFilter: false
},
{
accessorFn: row => {
let unpacked = ""
for (let i = 0; i < row.genres.length; i++) {
unpacked = unpacked + " " + row.genres[i].name
}
return unpacked
},
header: "Genres"
2024-06-12 15:15:22 +00:00
},
// {
// accessorKey: "deleted",
// header: "Deleted"
// },
]