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: "uniqueCode", header: "Code", cell: ({ row }) => {row.getValue("uniqueCode")}, }, { accessorKey: "assignmentMainType", header: "Type Task", cell: ({ row }) => { const type = row.getValue("assignmentMainType") as { name: string }; return {type?.name}; }, }, { accessorKey: "assignmentType", header: "Category Task", cell: ({ row }) => { const type = row.getValue("assignmentType") as { name: string }; return {type?.name}; }, }, { 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: "status", header: "Status", cell: ({ row }) => { const isActive = row.original.isActive; const isDone = row.original.isDone; let statusText = ""; if (isDone) { statusText = "Selesai"; } else if (isActive) { statusText = "Aktif"; } else { statusText = "Nonaktif"; } const statusColors: Record = { Aktif: "bg-primary/20 text-primary", Selesai: "bg-success/20 text-success", Nonaktif: "bg-gray-200 text-gray-500", }; const statusStyles = statusColors[statusText] || "default"; return ( {statusText} ); }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return ( View Edit Delete ); }, }, ]; export default columns;