import { ColumnDef } from "@tanstack/react-table"; import { Badge, Grid, Icon } from "@tremor/react"; import { Tooltip } from "antd"; import { UserInfo } from "./types"; import { PencilAltIcon, TrashIcon, InformationCircleIcon } from "@heroicons/react/outline"; export const columns = ( possibleUIRoles: Record>, handleEdit: (user: UserInfo) => void, handleDelete: (userId: string) => void, ): ColumnDef[] => [ { header: "User ID", accessorKey: "user_id", cell: ({ row }) => ( {row.original.user_id ? `${row.original.user_id.slice(0, 7)}...` : "-"} ), }, { header: "User Email", accessorKey: "user_email", cell: ({ row }) => ( {row.original.user_email || "-"} ), }, { header: "Global Proxy Role", accessorKey: "user_role", cell: ({ row }) => ( {possibleUIRoles?.[row.original.user_role]?.ui_label || "-"} ), }, { header: "User Spend ($ USD)", accessorKey: "spend", cell: ({ row }) => ( {row.original.spend ? row.original.spend.toFixed(2) : "-"} ), }, { header: "User Max Budget ($ USD)", accessorKey: "max_budget", cell: ({ row }) => ( {row.original.max_budget !== null ? row.original.max_budget : "Unlimited"} ), }, { header: () => (
SSO ID
), accessorKey: "sso_user_id", cell: ({ row }) => ( {row.original.sso_user_id !== null ? row.original.sso_user_id : "-"} ), }, { header: "API Keys", accessorKey: "key_count", cell: ({ row }) => ( {row.original.key_count > 0 ? ( {row.original.key_count} Keys ) : ( No Keys )} ), }, { header: "Created At", accessorKey: "created_at", sortingFn: "datetime", cell: ({ row }) => ( {row.original.created_at ? new Date(row.original.created_at).toLocaleDateString() : "-"} ), }, { header: "Updated At", accessorKey: "updated_at", sortingFn: "datetime", cell: ({ row }) => ( {row.original.updated_at ? new Date(row.original.updated_at).toLocaleDateString() : "-"} ), }, { id: "actions", header: "", cell: ({ row }) => (
handleEdit(row.original)} /> handleDelete(row.original.user_id)} />
), }, ];