Files
myeasycms-v2/packages/features/admin/src/components/admin-members-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

68 lines
1.5 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';
import { ProfileAvatar } from '@kit/ui/profile-avatar';
type Memberships =
Database['public']['Functions']['get_account_members']['Returns'][number];
export function AdminMembersTable(props: { members: Memberships[] }) {
return <DataTable data={props.members} columns={getColumns()} />;
}
function getColumns(): ColumnDef<Memberships>[] {
return [
{
header: 'User ID',
accessorKey: 'user_id',
},
{
header: 'Name',
cell: ({ row }) => {
const name = row.original.name ?? row.original.email;
return (
<div className={'flex items-center space-x-2'}>
<div>
<ProfileAvatar
pictureUrl={row.original.picture_url}
displayName={name}
/>
</div>
<Link
className={'hover:underline'}
href={`/admin/accounts/${row.original.id}`}
>
<span>{name}</span>
</Link>
</div>
);
},
},
{
header: 'Email',
accessorKey: 'email',
},
{
header: 'Role',
cell: ({ row }) => {
return row.original.role;
},
},
{
header: 'Created At',
accessorKey: 'created_at',
},
{
header: 'Updated At',
accessorKey: 'updated_at',
},
];
}