Files
myeasycms-v2/packages/features/admin/src/components/admin-memberships-table.tsx
giancarlo 13308194ec Update admin and marketing layouts, add new admin components
Refined both admin and marketing layouts for a clearer design. Newly added components for the admin page include admin-account-page, admin-members-table and admin-memberships-table. Also included in this update are route renaming, minor text edits and corrections in the code.
2024-04-08 20:00:52 +08:00

55 lines
1.1 KiB
TypeScript

'use client';
import Link from 'next/link';
import { ColumnDef } from '@tanstack/react-table';
import { Database } from '@kit/supabase/database';
import { DataTable } from '@kit/ui/enhanced-data-table';
type Membership =
Database['public']['Tables']['accounts_memberships']['Row'] & {
account: {
id: string;
name: string;
};
};
export function AdminMembershipsTable(props: { memberships: Membership[] }) {
return <DataTable data={props.memberships} columns={getColumns()} />;
}
function getColumns(): ColumnDef<Membership>[] {
return [
{
header: 'User ID',
accessorKey: 'user_id',
},
{
header: 'Team',
cell: ({ row }) => {
return (
<Link
className={'hover:underline'}
href={`/admin/accounts/${row.original.account_id}`}
>
{row.original.account.name}
</Link>
);
},
},
{
header: 'Role',
accessorKey: 'account_role',
},
{
header: 'Created At',
accessorKey: 'created_at',
},
{
header: 'Updated At',
accessorKey: 'updated_at',
},
];
}