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: "Pertanyaan", cell: ({ row }) => ( {row.getValue("title")} ), }, { accessorKey: "createdBy", header: "Pengirim", cell: ({ row }) => { const createdBy = row.original.createdBy; // Akses properti category return ( {createdBy?.fullname || "N/A"} ); }, }, { accessorKey: "sendTo", header: "Penerima", cell: ({ row }) => { const sendTo = row.original.sendTo; // Akses properti category return {sendTo?.fullname || "N/A"}; }, }, { accessorKey: "createdAt", header: "Waktu", 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}; }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return ( View Edit Delete ); }, }, ]; export default columns;