"use client"; import { type ColumnDef } from "@tanstack/react-table"; import { MoreHorizontal, Pencil, Archive, Trash2, ExternalLink } from "lucide-react"; import { DataTableColumnHeader } from "@/components/shared/data-table-column-header"; import { StatusBadge } from "@/components/shared/status-badge"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; interface VendorRow { id: string; name: string; website: string | null; notes: string | null; archived: boolean; createdAt: Date; _count: { filaments: number; resins: number; paints: number }; } interface VendorColumnsProps { onEdit: (vendor: VendorRow) => void; onArchive: (id: string) => void; onDelete: (id: string) => void; } export function getVendorColumns({ onEdit, onArchive, onDelete, }: VendorColumnsProps): ColumnDef[] { return [ { accessorKey: "name", header: ({ column }) => , cell: ({ row }) => (
{row.original.name} {row.original.archived && }
), enableHiding: false, }, { accessorKey: "website", header: ({ column }) => , cell: ({ row }) => row.original.website ? ( {new URL(row.original.website).hostname} ) : ( ), }, { id: "items", header: "Items", cell: ({ row }) => { const c = row.original._count; return ( {c.filaments + c.resins + c.paints} ); }, }, { accessorKey: "createdAt", header: ({ column }) => , cell: ({ row }) => ( {new Date(row.original.createdAt).toLocaleDateString()} ), }, { id: "actions", cell: ({ row }) => ( onEdit(row.original)}> Edit onArchive(row.original.id)}> {row.original.archived ? "Unarchive" : "Archive"} onDelete(row.original.id)} className="text-destructive focus:text-destructive" > Delete ), enableHiding: false, }, ]; }