-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolumns.tsx
More file actions
89 lines (83 loc) · 1.94 KB
/
Copy pathcolumns.tsx
File metadata and controls
89 lines (83 loc) · 1.94 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
"use client";
import { Link } from "nextjs13-progress";
import { ArrowUpDown } from "lucide-react";
import { ColumnDef } from "@tanstack/react-table";
import { Button, buttonVariants } from "@/components/ui/button";
import { Badge, BadgeVariants } from "@/components/ui/badge";
import { CaseColumn } from "@/types/CaseColumns";
export const columns: ColumnDef<CaseColumn>[] = [
{
accessorKey: "order_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 caseData = row.original;
return (
<Link
href={"/cases/" + caseData.case_id}
className={buttonVariants({ variant: "ghost", size: "xs" })}
>
{caseData.order_id}
</Link>
);
},
},
{
accessorKey: "status",
header: "Status",
cell: ({ row }) => {
const order = row.original;
let variant: BadgeVariants;
switch (order.status) {
case "answered":
variant = "success";
break;
case "pending":
variant = "processing";
break;
}
return (
<Badge variant={variant} className="mx-auto">
{order.status}
</Badge>
);
},
},
{
accessorKey: "companyId",
header: "Company",
},
{
accessorKey: "external_id",
header: "External No",
},
{
accessorKey: "enduser_name",
header: "End user",
},
{
accessorKey: "initials",
header: "Creator Initials",
},
{
accessorKey: "created_at",
header: "Created Date",
cell: ({ row }) => {
const order = row.original;
return order.created_at.toLocaleDateString("en-US", {
day: "2-digit",
month: "long",
year: "numeric",
});
},
},
];