-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolumns.tsx
More file actions
96 lines (90 loc) · 2.15 KB
/
Copy pathcolumns.tsx
File metadata and controls
96 lines (90 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"use client";
import { Link } from "nextjs13-progress";
import { ColumnDef } from "@tanstack/react-table";
import { ArrowUpDown } from "lucide-react";
import { type BadgeVariants } from "@/components/ui/badge";
import { Button, buttonVariants } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { ProposalColumn } from "@/types/ProposalColumns";
export const columns: ColumnDef<ProposalColumn>[] = [
{
accessorKey: "id",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
ID
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
cell: ({ row }) => {
const proposal = row.original;
return (
<Link
href={"/proposals/" + proposal.proposal_id}
className={buttonVariants({ variant: "ghost", size: "xs" })}
>
{proposal.proposal_id}
</Link>
);
},
},
{
accessorKey: "status",
header: "Status",
cell: ({ row }) => {
const order = row.original;
let variant: BadgeVariants;
switch (order.status) {
case "accepted":
variant = "success";
break;
case "cancelled":
variant = "disabled";
break;
case "pending":
variant = "processing";
break;
case "rejected":
variant = "destructive";
break;
}
return (
<Badge variant={variant} className="mx-auto">
{order.status}
</Badge>
);
},
},
{
accessorKey: "companyId",
header: "Company ID",
},
{
accessorKey: "order_id",
header: "Internal ID",
},
{
accessorKey: "external_id",
header: "External ID",
},
{
accessorKey: "initials",
header: "Initials",
},
{
accessorKey: "created_at",
header: "Created Date",
cell: ({ row }) => {
const proposal = row.original;
return proposal.created_at.toLocaleDateString("en-US", {
day: "2-digit",
month: "long",
year: "numeric",
});
},
},
];