'use client';

import { User } from '@/types';
import { ColumnDef } from '@tanstack/react-table';
import moment from 'moment';
import UsersAction from './users-action';

// This type is used to define the shape of our data.
// You can use a Zod schema here if you want.

export const usersColumns: ColumnDef<User>[] = [
    {
        accessorKey: 'name',
        header: 'Name',
    },
    {
        accessorKey: 'email',
        header: 'Email',
    },

    {
        accessorKey: 'balance',
        header: 'Balance',
    },
    {
        accessorKey: 'total_earning',
        header: 'Total Earning',
    },
    {
        accessorKey: 'created_at',
        header: 'Registration Date',
        cell: ({ row }) => <span>{moment(row.original.created_at).format('MMMM Do YYYY, h:mm:ss A')}</span>,
    },

    {
        id: 'actions',
        enableHiding: false,
        header: 'Actions',
        cell: ({ row }) => {
            const user = row.original;
            return <UsersAction user={user} />;
        },
    },
];
