181 lines
5.0 KiB
TypeScript
181 lines
5.0 KiB
TypeScript
|
|
"use client";
|
||
|
|
|
||
|
|
import { ColumnDef } from "@tanstack/react-table";
|
||
|
|
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
||
|
|
|
||
|
|
import { Button } from "@/components/ui/button";
|
||
|
|
import { Checkbox } from "@/components/ui/checkbox";
|
||
|
|
import {
|
||
|
|
DropdownMenu,
|
||
|
|
DropdownMenuContent,
|
||
|
|
DropdownMenuItem,
|
||
|
|
DropdownMenuTrigger,
|
||
|
|
} from "@/components/ui/dropdown-menu";
|
||
|
|
|
||
|
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||
|
|
import { Badge } from "@/components/ui/badge";
|
||
|
|
import { cn } from "@/lib/utils";
|
||
|
|
export type DataProps = {
|
||
|
|
id: string | number;
|
||
|
|
order: string;
|
||
|
|
customer: {
|
||
|
|
name: string;
|
||
|
|
};
|
||
|
|
date: string;
|
||
|
|
quantity: number;
|
||
|
|
amount: string;
|
||
|
|
status: "paid" | "due" | "canceled";
|
||
|
|
action: React.ReactNode;
|
||
|
|
};
|
||
|
|
export const columns: ColumnDef<DataProps>[] = [
|
||
|
|
// {
|
||
|
|
// id: "select",
|
||
|
|
// header: ({ table }) => (
|
||
|
|
// <Checkbox
|
||
|
|
// checked={
|
||
|
|
// table.getIsAllPageRowsSelected() ||
|
||
|
|
// (table.getIsSomePageRowsSelected() && "indeterminate")
|
||
|
|
// }
|
||
|
|
// onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
||
|
|
// aria-label="Select all"
|
||
|
|
// />
|
||
|
|
// ),
|
||
|
|
// cell: ({ row }) => (
|
||
|
|
// <div className="xl:w-16">
|
||
|
|
// <Checkbox
|
||
|
|
// checked={row.getIsSelected()}
|
||
|
|
// onCheckedChange={(value) => row.toggleSelected(!!value)}
|
||
|
|
// aria-label="Select row"
|
||
|
|
// />
|
||
|
|
// </div>
|
||
|
|
// ),
|
||
|
|
// enableSorting: false,
|
||
|
|
// enableHiding: false,
|
||
|
|
// },
|
||
|
|
{
|
||
|
|
accessorKey: "id",
|
||
|
|
header: "No",
|
||
|
|
cell: ({ row }) => <span>{row.getValue("id")}</span>,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "order",
|
||
|
|
header: "Judul",
|
||
|
|
cell: ({ row }) => (
|
||
|
|
<div className="w-52">
|
||
|
|
<span>{row.getValue("order")}</span>,
|
||
|
|
</div>
|
||
|
|
),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "customer",
|
||
|
|
header: "Kategory",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
const user = row.original.customer;
|
||
|
|
return (
|
||
|
|
<div className="font-medium text-card-foreground/80">
|
||
|
|
<div className="flex gap-3 items-center">
|
||
|
|
<span className="text-sm text-default-600 whitespace-nowrap">
|
||
|
|
{user?.name ?? "Unknown User"}
|
||
|
|
</span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "date",
|
||
|
|
header: "Tanggal unggah",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
return <span>{row.getValue("date")}</span>;
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "quantity",
|
||
|
|
header: "Kreator",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
return <span>{row.getValue("quantity")}</span>;
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "amount",
|
||
|
|
header: "Sumber",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
return <span>{row.getValue("amount")}</span>;
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "amount",
|
||
|
|
header: "Penempatan File",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
return <span>{row.getValue("amount")}</span>;
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "status",
|
||
|
|
header: "Status",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
const statusColors: Record<string, string> = {
|
||
|
|
paid: "bg-success/20 text-success",
|
||
|
|
due: "bg-warning/20 text-warning",
|
||
|
|
canceled: "bg-destructive/20 text-destructive",
|
||
|
|
};
|
||
|
|
const status = row.getValue<string>("status");
|
||
|
|
const statusStyles = statusColors[status] || "default";
|
||
|
|
return (
|
||
|
|
<Badge className={cn("rounded-full px-5", statusStyles)}>
|
||
|
|
{status}{" "}
|
||
|
|
</Badge>
|
||
|
|
);
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "amount",
|
||
|
|
header: "Kurasi Konten",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
return <span>{row.getValue("amount")}</span>;
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "amount",
|
||
|
|
header: "Saran",
|
||
|
|
cell: ({ row }) => {
|
||
|
|
return <span>{row.getValue("amount")}</span>;
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
id: "actions",
|
||
|
|
accessorKey: "action",
|
||
|
|
header: "Actions",
|
||
|
|
enableHiding: false,
|
||
|
|
cell: ({ row }) => {
|
||
|
|
return (
|
||
|
|
<DropdownMenu>
|
||
|
|
<DropdownMenuTrigger asChild>
|
||
|
|
<Button
|
||
|
|
size="icon"
|
||
|
|
className="bg-transparent ring-offset-transparent hover:bg-transparent hover:ring-0 hover:ring-transparent"
|
||
|
|
>
|
||
|
|
<span className="sr-only">Open menu</span>
|
||
|
|
<MoreVertical className="h-4 w-4 text-default-800" />
|
||
|
|
</Button>
|
||
|
|
</DropdownMenuTrigger>
|
||
|
|
<DropdownMenuContent className="p-0" align="end">
|
||
|
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||
|
|
<Eye className="w-4 h-4 me-1.5" />
|
||
|
|
View
|
||
|
|
</DropdownMenuItem>
|
||
|
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
||
|
|
<SquarePen className="w-4 h-4 me-1.5" />
|
||
|
|
Edit
|
||
|
|
</DropdownMenuItem>
|
||
|
|
<DropdownMenuItem className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none">
|
||
|
|
<Trash2 className="w-4 h-4 me-1.5" />
|
||
|
|
Delete
|
||
|
|
</DropdownMenuItem>
|
||
|
|
</DropdownMenuContent>
|
||
|
|
</DropdownMenu>
|
||
|
|
);
|
||
|
|
},
|
||
|
|
},
|
||
|
|
];
|