import * as React from "react"; import { ColumnDef } from "@tanstack/react-table"; import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react"; import { cn } from "@/lib/utils"; import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, DropdownMenuItem, } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { format } from "date-fns"; import { Link } from "@/components/navigation"; const columns: ColumnDef[] = [ { accessorKey: "no", header: "No", cell: ({ row }) => {row.getValue("no")}, }, { accessorKey: "title", header: "Title", cell: ({ row }) => ( {row.getValue("title")} ), }, { accessorKey: "categoryName", header: "Category", cell: ({ row }) => {row.getValue("categoryName")}, }, { accessorKey: "createdAt", header: "Upload Date", cell: ({ row }) => { const createdAt = row.getValue("createdAt") as | string | number | undefined; const formattedDate = createdAt && !isNaN(new Date(createdAt).getTime()) ? format(new Date(createdAt), "dd-MM-yyyy HH:mm:ss") : "-"; return {formattedDate}; }, }, { accessorKey: "tags", header: "Tag", cell: ({ row }) => {row.getValue("tags")}, }, { accessorKey: "statusName", header: "Status", cell: ({ row }) => { const statusColors: Record = { diterima: "bg-green-100 text-green-600", "menunggu review": "bg-orange-100 text-orange-600", }; // Mengambil `statusName` dari data API const status = row.getValue("statusName") as string; const statusName = status?.toLocaleLowerCase(); // Ubah ke huruf kecil // Gunakan `statusName` untuk pencocokan const statusStyles = statusColors[statusName] || "bg-gray-100 text-gray-600"; return ( {status} {/* Tetap tampilkan nilai asli */} ); }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return ( View Edit Delete ); }, }, ]; export default columns;