'use client';

import { Deposit } from '@/types';
import { ColumnDef } from '@tanstack/react-table';
import DepositAction from './deposit-action';

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

export const depositsColumns: ColumnDef<Deposit>[] = [
    {
        accessorKey: 'user.name',
        header: 'User Name',
    },
    {
        accessorKey: 'investment_plan.name',
        header: 'Investment Plan',
    },
    {
        accessorKey: 'amount',
        header: 'Amount (USDT)',
    },
    {
        accessorKey: 'payment_method.name',
        header: 'Payment Method',
    },

    {
        accessorKey: 'status',
        header: 'Status',
        cell: ({ row }) => (
            <span
                className={`rounded-full px-2 py-1 text-xs font-medium capitalize ${
                    row.getValue('status') === 'completed'
                        ? 'bg-green-100 text-green-800'
                        : row.getValue('status') === 'pending'
                          ? 'bg-yellow-100 text-yellow-800'
                          : 'bg-red-100 text-red-800'
                }`}
            >
                {row.getValue('status')}
            </span>
        ),
    },
    {
        id: 'created_at',
        header: 'Created At',
        cell: ({ row }) => {
            const createdAt = row.original.created_at;
            console.log(createdAt);
            return <span>{new Date(createdAt as string).toLocaleDateString()}</span>;
        },
    },
    {
        id: 'actions',
        enableHiding: false,
        header: 'Actions',
        cell: ({ row }) => <DepositAction deposit={row.original} />,
    },
];
