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: (key: string) => string } }) => { const title: string = row.getValue("title"); return ( {title.length > 50 ? `${title.slice(0, 30)}...` : title} ); }, }, { accessorKey: "categoryName", header: "Category Name", 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: "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: "isDone", header: "Status", cell: ({ row }) => { const isDone = row.getValue("isDone"); return (
); }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return ( View Edit Delete ); }, }, ]; export default columns;