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 { format } from "date-fns"; import { Link } from "@/i18n/routing"; const columns: ColumnDef[] = [ { accessorKey: "no", header: "No", cell: ({ row }) => (

{row.getValue("no")}

), }, { accessorKey: "title", header: "Title", cell: ({ row }: { row: { getValue: (key: string) => string } }) => { const title: string = row.getValue("title"); return ( {title.length > 50 ? `${title.slice(0, 10)}...` : title} ); }, }, { 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: "fileTypeName", header: "Type Content", cell: ({ row }: { row: { getValue: (key: string) => string } }) => { const title: string = row.getValue("fileTypeName"); return ( {title.length > 50 ? `${title.slice(0, 30)}...` : title} ); }, }, // { // accessorKey: "creatorGroup", // header: "Creator Group", // cell: ({ row }) => ( // {row.getValue("creatorGroup")} // ), // }, // { // accessorKey: "creatorName", // header: "Sumber", // cell: ({ row }) => ( // {row.getValue("creatorName")} // ), // }, // { // accessorKey: "publishedOn", // header: "Published", // cell: ({ row }) => { // const isPublish = row.original.isPublish; // const isPublishOnPolda = row.original.isPublishOnPolda; // let displayText = "-"; // if (isPublish && !isPublishOnPolda) { // displayText = "Mabes"; // } else if (isPublish && isPublishOnPolda) { // displayText = "Mabes & Polda"; // } else if (!isPublish && isPublishOnPolda) { // displayText = "Polda"; // } // return ( //
// {displayText} //
// ); // }, // }, { accessorKey: "statusName", header: "Status", cell: ({ row }) => { // Mendapatkan nilai statusName const statusName = row.getValue("statusName"); // Mapping warna berdasarkan statusName const colorMapping: Record = { "Menunggu Review": "text-orange-500 border-orange-500", Diterima: "text-green-500 border-green-500", "Minta Update": "text-blue-500 border-blue-500", Ditolak: "text-red-500 border-red-500", }; // Mendapatkan kelas warna dari mapping, default ke abu-abu jika tidak ditemukan const buttonClass = colorMapping[statusName] || "text-gray-500 border-gray-500"; return (
); }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return ( View Delete ); }, }, ]; export default columns;