import type { ColumnDef } from '@tanstack/table-core';
import type { Signature } from '$lib/api/dashboard/a76/general_catalogs/signatures';
import { renderComponent } from '$lib/components/ui/data-table';
import DataTableActions from './data-table-actions.svelte';

export function createColumns(
    onSuccess?: () => void,
    { canEdit = true, canDelete = true }: { canEdit?: boolean; canDelete?: boolean } = {}
): ColumnDef<Signature>[] {
    return [
        {
            accessorKey: 'code',
            header: 'Código',
            cell: ({ row }) => row.original.code || 'N/A'
        },
        {
            accessorKey: 'signature',
            header: 'Firma',
            cell: ({ row }) => row.original.signature ?? 'N/A'
        },
        {
            accessorKey: 'photo_path',
            header: 'Ruta Foto',
            cell: ({ row }) => row.original.photo_path ?? 'N/A'
        },
        {
            id: 'actions',
            header: 'Acciones',
            cell: ({ row }) => renderComponent(DataTableActions, {
                item: row.original,
                onSuccess,
                canEdit,
                canDelete
            })
        }
    ];
}
