Skip to content

Commit fada939

Browse files
authored
Adds sorting to contributors table (#6)
1 parent be89ba3 commit fada939

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/app/(dashboard)/contributors/columns.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { Button } from "@/components/ui/button";
4-
import { MoreHorizontal } from "lucide-react";
4+
import { ArrowUpDown, MoreHorizontal } from "lucide-react";
55
import {
66
DropdownMenu,
77
DropdownMenuContent,
@@ -38,23 +38,44 @@ export const contributorsColumns: ColumnDef<ContributorDto>[] = [
3838
},
3939
{
4040
accessorKey: "contributionScorePercentage",
41-
header: () => <div className="text-center"> Impact </div>,
41+
header: ({ column }) => {
42+
return (
43+
<Button
44+
variant="ghost"
45+
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
46+
className="flex items-center"
47+
>
48+
Impact
49+
<ArrowUpDown className="ml-2 h-4 w-4" />
50+
</Button>
51+
);
52+
},
4253
cell: ({ row }) => {
4354
const contributor = row.original;
4455
return (
45-
<div className="text-xl font-bold text-center">
56+
<div className="text-xl font-bold text-left pl-4">
4657
{contributor.contributionScorePercentage.toFixed(2) + "%"}
4758
</div>
4859
);
4960
},
5061
},
5162
{
5263
accessorKey: "contributionScore",
53-
header: () => <div className="text-center"> ContributionScore </div>,
64+
header: ({ column }) => {
65+
return (
66+
<Button
67+
variant="ghost"
68+
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
69+
>
70+
Contribution Score
71+
<ArrowUpDown className="ml-2 h-4 w-4 flex items-center" />
72+
</Button>
73+
);
74+
},
5475
cell: ({ row }) => {
5576
const contributor = row.original;
5677
return (
57-
<div className="text-xl font-bold text-center">
78+
<div className="text-xl font-bold text-left pl-14">
5879
{contributor.contributionScore.toFixed(2)}
5980
</div>
6081
);

0 commit comments

Comments
 (0)