import type { ColumnDef, Row } from '@tanstack/react-table';
import type { ReactNode } from 'react';

type Props<TData> = {
    cell: (row: Row<TData>) => ReactNode;
};

export function createActionsColumn<TData>({
    cell,
}: Props<TData>): ColumnDef<TData> {
    return {
        id: 'actions',
        enableSorting: false,
        enableHiding: false,
        header: () => (
            <span className="block w-[6.75rem] min-w-[6.75rem] text-right text-sm font-medium whitespace-nowrap text-muted-foreground">
                Actions
            </span>
        ),
        cell: ({ row }) => (
            <div className="flex w-[6.75rem] min-w-[6.75rem] flex-nowrap justify-end gap-1">
                {cell(row)}
            </div>
        ),
    };
}
