diff --git a/components/scoreplaylog/colums.tsx b/components/scoreplaylog/colums.tsx index 49e68ee..0647587 100644 --- a/components/scoreplaylog/colums.tsx +++ b/components/scoreplaylog/colums.tsx @@ -12,11 +12,10 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { Badge } from "@/components/ui/badge"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { generateShareToken } from "@/app/(sharing)/[token]/token"; - +import { ArrowUpDown, MoreHorizontalIcon } from "lucide-react"; import { chuni_score_playlog } from "@/prisma/schemas/artemis/generated/artemis"; import { chuni_static_music } from "@/prisma/schemas/artemis/generated/artemis"; import { getGrade } from "@/lib/helpers"; @@ -48,7 +47,17 @@ export const columns: ColumnDef[] = [ { accessorKey: "score", - header: "Score", + header: ({ column }) => { + return ( + + ); + }, cell: ({ row }) =>
{row.original.score?.toLocaleString()}
, }, { @@ -69,7 +78,17 @@ export const columns: ColumnDef[] = [ }, { accessorKey: "userPlayDate", - header: "Date", + header: ({ column }) => { + return ( + + ); + }, }, { accessorKey: "difficulty", @@ -94,6 +113,7 @@ export const columns: ColumnDef[] = [ { accessorKey: "Attempts", header: "Attempts", + cell: ({ row }) => (
{row.original.playCount}
), diff --git a/components/scoreplaylog/data-table.tsx b/components/scoreplaylog/data-table.tsx index a87a3dd..ffbc15c 100644 --- a/components/scoreplaylog/data-table.tsx +++ b/components/scoreplaylog/data-table.tsx @@ -2,6 +2,8 @@ import { Button } from "@/components/ui/button"; import { ColumnDef, + SortingState, + getSortedRowModel, flexRender, getCoreRowModel, getPaginationRowModel, @@ -16,6 +18,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; +import { useState } from "react"; interface DataTableProps { columns: ColumnDef[]; @@ -26,12 +29,18 @@ export function DataTable({ columns, data, }: DataTableProps) { + const [sorting, setSorting] = useState([]); + const table = useReactTable({ data, columns, - getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), + onSortingChange: setSorting, + getSortedRowModel: getSortedRowModel(), + state: { + sorting, + }, }); return (