"use client"; import { ColumnDef } from "@tanstack/react-table"; import { DateWithTime } from "@/components/ui/entities"; import { DataTableColumnHeader } from "@/components/ui/table"; import { RolesProps } from "@/types"; import { DataTableRowActions } from "./data-table-row-actions"; const getRoleAttributes = (row: { original: RolesProps["data"][number] }) => { return row.original.attributes; }; const getRoleRelationships = (row: { original: RolesProps["data"][number]; }) => { return row.original.relationships; }; export const ColumnsRoles: ColumnDef[] = [ { accessorKey: "role", header: ({ column }) => ( ), cell: ({ row }) => { const data = getRoleAttributes(row); return (

{data.name[0].toUpperCase() + data.name.slice(1).toLowerCase()}

); }, }, { accessorKey: "users", header: ({ column }) => ( ), cell: ({ row }) => { const relationships = getRoleRelationships(row); const count = relationships.users.meta.count; return (

{count === 0 ? "No Users" : `${count} ${count === 1 ? "User" : "Users"}`}

); }, }, { accessorKey: "invitations", header: ({ column }) => ( ), cell: ({ row }) => { const relationships = getRoleRelationships(row); return (

{relationships.invitations.meta.count === 0 ? "No Invitations" : `${relationships.invitations.meta.count} ${ relationships.invitations.meta.count === 1 ? "Invitation" : "Invitations" }`}

); }, }, { accessorKey: "permission_state", header: ({ column }) => ( ), cell: ({ row }) => { const { permission_state } = getRoleAttributes(row); return (

{permission_state[0].toUpperCase() + permission_state.slice(1).toLowerCase()}

); }, }, { accessorKey: "inserted_at", header: ({ column }) => ( ), cell: ({ row }) => { const { inserted_at } = getRoleAttributes(row); return ; }, }, { accessorKey: "actions", header: () =>
Actions
, id: "actions", cell: ({ row }) => { return ; }, }, ];